All right, in this lecture, we're going to talk about how we can do page emulation on playwrite.
I mean, if you remember, we already discussed about the simulation while we were talking about broader
context and stuff.
That's exactly what we're going to be doing in this particular video aspect.
What I'm going to do is I'm just going to create a concept here and then I'm going to do something like
Devizes where I'm just going to do a required of playwrite.
Or you can also do a come off for Devizes over here, which does the exact same thing.
You don't have to do like two requires over here.
And once you have this, you can then set the devices that you want to emulate for.
So if you remember in our earlier video when we were working, we actually set the simulation over here.
Something like concept of iPhone is equal to Devizes of iPhone, Leverne Pro or something like that.
So you can choose that particular option and then you can set the devices.
So in order to set the simulation, you actually need to set the simulation on the context level.
So if you remember that something very, very important, you need to set that on the context level
and not on the browser level or something like that.
So for doing that, you're going to actually do it over here on this particular context that specify
the device as the iPhone, which is quite good.
And once you have this, you can also specify the video part if you want to.
If you remember, we already have this particular video iPod where we can do things.
So I can just do a video iPod and I'm going to specify.
Video over here.
Or you can just specify a folder name that you want to choose so you can do that as well, which is
quite good.
So this way you can actually do the emulation of the browser page based on the device landscape that
you are looking for.
So I'm just going to do a node of.
The PDF Dages I'm actually doing it everything on the PDF itself instead of just.
Creating a new one, because this makes much better sense, you can see that on this particular Malaysian,
it really didn't find that particular that particular login username and password does actually have
to scroll that a bit.
So we actually need to see how we could able to do that.
But instead of the landscape, probably I'm just going to go with the Permax and if I try running it
once again.
You can see that now the browser is launching on a perfect size, but we actually need to click the
username and password, something like this, because this is where it holds those information for you.
Uh.
I think that's it and once again, the PIDF is not going to work because you remember it's because of
the Headful mode.
Yeah, but you can see that it is actually working fine as expected.
So this is how you can actually see that the emulation can be done.
But there are many different other things that you can do on the same emulation site.
You can also not only just change the size of the screens, but you also can set the location.
You can also set the view boards and you can set the time zones, permissions and user agents, et cetera.
So, I mean, you can set everything you want on this particular level.
So all these things, you can easily do it from this particular emulation options.
So what I'm going to do is I'm actually going to probably because it's going to be ruining our PDF dodgiest
file.
I'm just going to call this Ghias emulate Dargis file, and I'm just going to probably remove these
things, which we have it over here.
From the PDF so that you will have a pristine state code that's going to save this, also the headless
something in the moon and on the Immler charges filed, what we can do is we can try doing the options
of working with the immolations itself.
So you can see that this code is pretty legal, which we know that.
And if you want to set the viewport, you can set the viewport as well.
So this is the iPhone and this is the iPhone level set on the context.
We can also set something called as viewport that within this viewport, you can specify how much size
that you need to set the viewport for.
And because we know that for the iPhone, the viewport is going to be a bit different then compared
to the browser itself.
If I tried to set like a viewport of a huge size, probably then the the way it is going to render is
going to be different as well.
So if I try to run the emulator JS file.
You can see that the iPhone has been overridden, but the viewport has taken into presidents this time.
So basically, if you set the viewport, you should insert the iPhone because it doesn't really make
sense, because iPhone screen size is not like two thousand twenty thousand two and a half thousand
twenty four.
Right.
So you need to make sure that you don't do two combo at the same time, because basically it's like
riding the particular option.
And you can also set the scale and the time zone off your side if you want to test the side based on
the different time zones, if you want to.
So those things you can do as well.
So you can do something like location and the time zone just like that.
And if you try to run that, it is going to run based on that particular time zones.
And you can also set something like geo locations and permissions, like how we saw in our earlier video
while discussing on the browser context.
So those things you can do on the browser context level while doing the emulations.
So these things are something which is available on the playwright for you to do a different modern
way of testing on the browsers and see how it actually works.