All right, just in this section and a couple of other section in this cause, I'm going to be discussing
fuel concepts of playwrite in my Windows machine.
So I've been working with the MacBook Pro, with Apple and one power chip in my earlier sections.
But in this section, just to show some of the cross platform ability, like how you can run the exact
same code on the windows as well as in the Mac, I'm going to be using Mac this time.
So there is no reason why I have switched to the Windows machine.
It's exactly the same idea.
I'm going to be using it in my windows so you can I mean, for the Windows user, if you're going to
run the test and you're going to use it, you will see that I'm not going to do any code change and
the code is going to work pretty much exactly how it works on my MacBook Pro as well.
But as I said, I have already done under the code from our earlier section where we discussed about
some of the basics of the playwright.
And now I have the dual dependency of the play right over here.
And now I also need to install the playwright, a test runner so far doing that.
I'm just going to open the terminal.
I'm going to do and probably search for.
Playwright IFN, I test this guy and I'm just gonna say it, and then I'm going to do an NPM install.
And you can see that this insulation is going to be pretty much exactly like how I did in my Mac and
one that's also happening in my Windows machine as well.
I have installed the record notice and all of the things the insulation is going to be pretty much exactly
like how it happens in in my Mac and one as well.
So the first thing which I'm going to do this time is I'm going to create a folder and then I'm going
to call this as just a runner.
And then within this test, I'm going to create a file.
So basically, I'm just trying to isolate the existing test with the code that we'll be discussing in
this section, because it's going to be an all new section.
And we have a lot of things to discuss in the section.
So I'm just creating a new folder there.
And then I'm going to create a very, very simple test this time and we'll see how we can run our test
using the test runner of playwrite.
So far doing that, I'm just going to do this test run a demo doc spec and you can see that I'm actually
using a key word there spec.
This is pretty much like how we did with our just test runners.
So that's exactly the way that you can use this to run the test.
And then for the first time in this course, we are going to be using the typescript.
So I'm intentionally using the typescript because this is what the team recommends.
And I guess we should be slowly moving towards the typescript area.
And I have already covered many of the details on the typescript in my YouTube series are probably I
can pay that particular video as in section in the scores.
But yes, TypeScript is really, really cool.
So we are going to be using the typescript this time.
So this is the file that it has created right now for the typescript.
And all I want to do is I'm going to start writing a super, super simple test and we'll see how it
actually works.
So as I told you before, it is very, very simple, guys.
All we have to do is we have to just do an import, let's do an import, see here import.
And then I'm just going to open and close the.
Is there and then I'm going to do this ad and you can see that once I open the double because it tells
me that playwrite hyphen playwright's test.
So this is the one which we are looking for and we can just import it over here.
So this is the image I'm talking about.
So if you just type described piquancy that describes comes in and then you can see expect comes in
as well.
If you want to do and expect verification there, you can do all sorts of things using this particular
import statement.
And then we can write a simple code, as I told you before, so we can do this ID and then we're going
to say that first test for simple demo and I'm just going to do a open or close parenthesis over here.
And then if you don't really specify anything, that test will just exit without any problem.
I mean, you can just do a console dialog and then you can just try to see, hello, uh, test something
like this.
You can specify that and then you can run the test by going to this particular directly, which is going
to be the code of the test runner.
And then as I told you, in order to execute this test, you need to use this command NPCs and then
Foleo.
So if you specify the NPCs Foleo, it is going to run the test pretty quickly and pretty instantly.
You can see that it tells told you that it is going to run the test and it ran the test using one worker.
And then you will be asking what is this one worker is all about?
Just hold tight.
We're going to talk about that in a minute.
But yes, this is how it actually executes the test.
Using this particular command, NPCs are folia, so you can see that I have not even specified the file
name, if there are five or six different files, is going to execute all the files with that spec dot
these extensions.
So if you have another file, the extension is going to execute all the test files for you.
So you can also do like this or NPCs Foleo and then you can give the file name and if you execute that,
then it is going to exist only that particular file.
So this is another way that you can do it.
But now comes word as we really fit this with our playwrite itself, because this is just a disgruntled
demo that we have seen.
But where is the playwright comes in again?
That's a good question.
So in order for that, what I'm going to do is I'm just going to do a copy and paste over here and I'm
going to say first test to navigate a site demo.
And over here, I'm just going to do this, I think.
Now you can see that I'm just bringing in the, I think context the keyword here.
And then I'm just going to bring in the context.
And once you want to type this context, you can see that automatically it brings context, context,
factory, context, options is chrome.
I mean, there are these things coming from and how does it knows that I'm actually going to be playing
around with these things right now.
So let me just put this context over here and let me just do a control click and you can see that it
brings me up a whole new index dart deducts file or a type definition's file.
So this type definition file has been created by Microsoft Corporation.
And you can see that it has a type four browser browser context of conduct options, prototype launch
options and page from playwrite.
So basically they are going to be using playwrite for actually importing all these important types that
we have been using in our existing test, or pretty much exactly how we used in our puppeteer's and
stuff.
So this is exactly what comes for the playwright as well.
And then they actually has a type for playwrite parameters.
So they have different types of Fatimata like browser name.
So it tells you that Chrome, Firefox and Webcke and they have had full a Boolean type and you can see
lots of entry to Linux or Darrion platforms, screenshots and stuff.
Similarly, playwright to worker fixtures and playwrite test fixtures.
And this is the one which we actually got about the context option, right in the context.
So basically we use this particular context when we ran this test fixture, and it is basically a browser
context.
So if I just go over here and if I hoer there, you can see that it tells me that the content is basically
a browser context and that's what it came over here.
And similarly, Foleo and now you can see that it says in portfolio and it gets a lot of details about
it.
I mean, don't worry about it.
We are going to be talking about this folios, you know, upcoming videos of this course.
But yeah, this is what is the context and this is how it actually gets this particular context.
So we discuss really a lot deeper into how the interior functionality works.
But let me quickly show you how we can spawn a browser page and how we can use it.
And because we have this particular browser context and we know what browser basically does.
Right?
I mean, we discussed about that in our earlier videos of our course, like Playwrite, our Firefox
that launched the new context.
Basically, this new context is a browser context options.
And this is what we discussed in our earlier videos as well.
And that's exactly what we'll be doing in this particular page as well.
So what I'm gonna do is I'm going to create a page.
I'm going to do, in a way out of the context DOT new page.
We know this one, right?
I mean, it creates a new page and it is very helpful while we try to use it with a multipage options
and stuff.
So that's exactly the same kind of code that we are using over here and we are going to do and a way
weight of page dot.
We can do a go to here and then we can specify the website that you want to go.
For example, has a DB column, double slash, let's say Neo in dot net, and then we can also probably
get a value or maybe click anything over there.
I mean, we can do a lot of things.
I mean.
Right.
I mean those things are something which we know already.
We discussed about it a lot in this course.
So I'm just going to leave it as it is.
And I'm just going to run this particular test and I will show you what it happens.
And you can see that this time it tells me it's running for test.
Using for workers, what does it really mean?
So if you remember the slide, right, I told you that every time if you call the Foleo Inpex Foleo,
it will actually run the test using three different browsers.
One is on the chrome, one is on the Firefox, and another one is on the chromium.
So it actually executed all the test on three different browser this time.
And that is why it was back for test using for the workers.
And this is another test that we have.
So this is one, two, three test basically.
And this one is like one test.
And now if I want to specify, maybe if I just want to run just with the browser as probably like Firefox
so I can just specify something like iPhone hyphen programs, which is going to be, I guess, its browser
name as Firefox or something like that, or the name is equal to Firefox.
Sorry, I don't remember that.
Let me just go here.
Yeah.
Browser name is sequel to Firefox.
Just going to specify Präsident sequel to Firefox hit Enter.
I guess it's Perram, not prom's.
And you can see that this time it's only running to test using two workers, so basically this is one
test and this is another test and it is working with just one browser, which is the Firefox browser.
But you can see that it is currently not showing us the browser coming up over here because I don't
really have specified the headless more to be fun.
I mean, I would make it like headful.
So, you know that by default the behavior of the puppeteer or playwrite is headless.
So we need to specify the headful or whatever it is.
So now I have specified Headful State and now you can see that there is a browser being pond and it's
going to the niobium dot com website for us and it's waiting for the page to fully load.
And once this fully loaded, the test is completed.
Awesome.
So this is how we could see that we could able to use this tester runner in playwrite much, much simpler.
And this is pretty awesome.
So we'll be discussing even more detail or upcoming videos of this course.
Stadion, talk to you in our next video.