All right, so now that we know the theoretical aspects of the Foleo parameters and how we can actually
work with the flow parameters and stuff, but now we're going to write the actual code and we'll see
how we can create the Foleo parameters and how we can run the test using the Foleo parameters sonorant
for doing that.
I'm going to go back to the Foleo example that we wrote where we actually understood how we can create
our own fixtures and this time we're going to create our own fixture once again, but with the parameter
options.
So I'm going to create a new file.
I'm going to call this as a fixture, Parum Dot Ts.
And over here I'm going to start writing the code.
So again, we need to do this import that we always do.
So I'm just going to do something like from and playwrite test.
And then over here we need to get the folio as our base, which is something we did in our earlier video
as well.
And then we need to do an export of the expect something like this and then we need to declare the new
fixture as a parameter like how we saw on the on the slide.
So that card is going to look something like this.
So I'm trying to do is I'm just going to do a base of extend where I'm going to be creating two parameters.
One is for the browser and another one is for the vision.
And then I'm just going to use these parameter value to be parsed during the command line.
And I also need to set the default value.
For some reason, if we just run the folio of the Inpex folio and the test name, then it is going to
run this particular default description and value for me.
So this is something like every time you run the test, you're going to always choose the browser version
as Eighty-six.
If you don't specify that in the parameter, if you do specify the browser version on the parameter,
then it is going to use that particular version for you.
And once again, as I told you, in order for a running the the browser, we are going to actually perform
the init operation of the fixture, something like this.
And as you can see over here for the first time, we are actually using a scope of worker.
And this particular code, as we saw on the slide, is just an efficient condition where if the version
that I'm trying to pass in from the parameter is going to be like greater than add than just print like
that.
If it is smaller than 80, then it's going to be this one.
Yeah.
So this is how it is going to be.
It's designed to run for that particular browser on this fixture.
That's it.
So this is the only change that we need to do.
And the rest of the code is going to be pretty much like this.
I mean, we need to export the ID of the folio so that we can access it from the test that we are going
to be executing.
So once we do that, we can now try to execute this code using this particular fixer.
Param starts and we'll see how it actually works.
So this is very, very simple.
All we're trying to do is we are going to use this init parameter this time, which is going to be useful
for us to perform the operation that we are looking for.
So now that I'm going to use another test, probably because we are going to be working on the work
or we are going to call this houseworker dart spec darts where I'm actually going to be calling this
particular fixer upper arm and we'll see how it actually works for that.
I'm just going to go to the import of from dot slash, fix it from and we are going to be importing
the it.
So I'm just going to call it over here and I'm just going to write the test method using the it.
So I'm just going to say it.
Let's a browser
version test and here I'm just going to call the async like how we used to do that.
I'm going to pass the let's say I'm going to pass the browser probably.
And once it is done, then we can actually try to run the test and see how it actually works.
I'm just going to do a console dart log of probably the browser that I'm just trying to pass in that
says so this is a super simple test.
I just want to make a point here that how we can actually run the test from the command line and how
we can execute it using the parameter.
So far doing that, I'm just going to go to to the Khedive
Foleo example and we're going to do NPCs Foleo of.
Workers, spectators file.
So now if I try to run without passing any parameter, and as I told you before, if you don't pass
any parameter, then it is just going to invoke this particular in problem for us.
So let's try to execute this and see what actually happens.
So we get an error here.
And it says that the browser has already been registered.
Use the override to override doing a specific test file.
And because we know that if we use something like a browser, this browser is actually available in
our playwrite parameter, as you can see over here.
So if I just click this, do you see that the index drops file over here where it shows that playwrite
worker fixture where it actually has something called as browsers?
So basically browser in the sense over here, it's because it tells you that the browser is actually
available.
So in order to resolve this problem, there are two way we can actually do this to resolve this problem,
to fix this issue.
Basically, one is we can directly use something called S Foleo over here to try to run this particular
test without using the playwrights test.
We can directly get the directive from the Foleo.
And then if you try to run this particular test, it is going to work as expected as you can see over
here.
Or we can also do something like a changing of this particular name from browser to browsers, something
like that.
I mean, this is not something registered or maybe like browser.
Yeah, browsers should be fine because I don't think it has been registered somewhere and this is pretty
good.
And now if I go back to my test, let's change this to browsers like that.
Say it.
And now if I tried to run this test, hopefully it is not registered anywhere.
And you can see that this test is also working fine.
But again, for some reason, it is actually calling the Firefox.
And I think this browser is also registered somewhere on the on the worker's back.
And for some reason, I could see that it is actually calling the real browsers in here.
So this is also not the right way of doing it.
So better that you just use a different naming convention for the browser, because the browser is I
think it is also registered in the playwright to work with the different browsers.
So instead of using this, if you just tried to use something like Abreau or something like that, like
this is the name which I don't think is available anywhere on the register code of the playwright.
So if I tried to exclude this.
Oops, I'm getting an error because I think it is not being saved, as you can see here, there is a
dark there, which means it is not saved to save the file.
And if I tried to execute this, now you can see that it is working as expected.
So basically, it should not be browser or browsers or something like that because it's been used by
playwrite somewhere in their internal services.
So I cannot just mess up with that.
It's already been registered with playwrite, so let's not use that though.
So but so you got the idea, right?
I mean, you can pause this and you get this particular vergence, like running the latest version of
the browser and use the new driver because it is automatically taking the version number 86 and then
the current version.
And so us eighty-six and then it is parsing.
And that is the reason you can see that this particular test is actually working fine without any problem.
But now there is another cache that you can do instead of the browser in here, let's say if I want
to get this particular version.
So I just want to print the version and I want to run this test this time.
So if we call this version, this is going to initialize this particular parameter alone.
So whatever parameter that you're going to pass in is going to be executed for you.
So if I tried to execute this test, you can see that the printing value changes this time.
So instead of this running latest version of browser use, new driver current version is eighty six.
It is just printing the values 86, which is nothing but this one.
So only this particular init parameter is being called.
You can also see this using the parameter that we can pass from Parum hyphen P version is equal to eighty
nine or something like that.
If I tried to run this, you can see that it only overrides the value, the default value from eighty
six to eighty nine and then it prints that particular value.
But because the reason is our test is actually using the version as the parameter over here, that's
what it is using from the fixed parameter to initialize as well.
And that's exactly what we discussed even in the fixture while we were discussing over here with the
different prototypes.
So this time, instead of the version, let's say, if I want to use the pro, I think it's pretty bad
name, though, for the programming constructor at least.
And now if I just put Bre over here and if I tried to run the version of eighty 89, something like
that, you can see that it tells running one test, using one worker for this particular version, number
89.
And now let's make another trick.
So that's what is the power of this particular parameter.
It's like if we want to use two different version, let's say 89 and it's a forty which is a lawyer
version.
So you should be getting a different message.
So if I run this time, you will see that there'll be two test running using two workers so it automatically
respond to working for us.
And then it says that running all the original browser and users, the older driver, the current version
is 40, whereas it says the running latest version of browser use new driver current version is eighty
nine.
So that I'd like to print a happened here for two workers test been executed.
So that's what I was talking about.
We now have the ability to control the test based on the configuration that we can specify on our test
and we can posit from the parameter using the Foleo parameters.
So guys, this is about the FOLIA parameter.
Let's meet in our next video to talk about the skip test.