So don't ask, we do have a discussion about Browsr a lot, and in this video we can talk about broader
context if remember what we tried to do, a recording and playback of the with the playwright Seelie,
we saw the code automatically generated the browser, the new context.
So this new context, as I told you, is like a browser context, which is responsible for creating
a lightweight context, basically.
So if you don't really see this in action, you can actually see this in a more meaningful and more
easier way.
So what I'm going to do is I'm going to create a new context here and we'll call this as probably context
to something like that.
I might use the same browser as you can see the browser of new context, but I'm using context to over
here in this context, too.
I'm going to create a new page as well.
So I'm just going to keep all these things as it is.
Um, well, copy paste, this is going to be a page to confess to.
And within page two, I'm going to be navigating to let's call it automation dot com and I'm going to
take a screenshot or something like that.
Yeah.
So this is a different context and this is going to be a separate contest altogether.
I'm just going to save this.
And now if I try to run this court, you will see what's going to happen.
So the first time it launches the browser, it took some time to launch.
I mean, you don't really see the difference between both of them, but you can see that once the test
is fully executed, it is going to open another browser, which is quite faster, actually.
I mean, we don't really see those two difference at the moment.
But, yes, there are a difference.
So if I just close this test, probably the Firefox was quite slow in my machine, so I'm just going
to go remotely slow.
I'm just going to say this.
Let's change this to Firefox.
I think that was literally visible.
I'm just going to copy this pasted over here and I'm going to run them now.
So you can see that it took some time actually to launch the browser.
And you can see that this guy is launching pretty faster as well.
So it shows the point that you are actually using a different context altogether and they don't really
talk with each other.
So this context, a context, too, has no relation with context itself.
So if this context has got any logging operation done for, let's say, a Wikipedia page, then the
context to which is going with a net zero automation page has got no relation with it.
And it won't even care like what cookies and stuff are there, because browser context is basically
like an incognito operation, which you are doing while you perform any operation.
It's also a good practice that once you're done with executing, you should close that particular context
as well.
So that is one of the another important thing that you should be doing.
And within this new context, you can also do a different set of operations, like you can set the permissions
and then you can set the geolocation and stuff.
So if you say within this particular context, let's say if I want to open this context, something
like this, and if it lets let's say if I just go to the definition of this new context, you can see
there is something called a browser context option.
So let me go here.
There is something called the browser context option.
So if I go to the browser Kandace option interface, you can see it says except downloads ignore has
errors bypass kesby viewport, user agent device scale factors has touch times on ID, geolocation,
local permissions, extra hacerte beheaders, offline color schemes, video part.
I mean we are not even talked about really about yet.
We talk about that later.
But yes, you can do that.
And similar regard, the hard file which is going to be your whole analytics transactions and stuff
like FSR transactions and then record with what is the different properties that its director going
to stay on, things proxy's storage, dead and stuff.
So you can do a lot of things with this particular context alone.
So it's quite different from the browser launch option because the browser context option is different
from the launch option completely because this is a different context altogether.
But here we can also do some sort of manipulations of the browsers, like because it has the device
context that you can also do that.
So if you don't really get what I mean, how did we change this to chrome game like chromium over here?
And I'm going to call.
So if you go to this particular constant, you can see that we have something called US Devices Constant,
which is responsible for all the devices and devices descriptors.
So this is very, very helpful while you work with the different devices.
So if you go to the device descriptors, you can see that are different device descriptors are available
like viewport strings of user agent device scale factors is mobile, has touch and defined mobile browser
and stuff.
So this is very, very handy.
When you work with those particular devices, you can set all those things.
And I'm also going to do one more thing in here.
I'm just going to set constant of iPhone Zolta devices off.
Once I hit Colline, it automatically brings all the device properties for me.
So let's say I want to use my iPhone.
So there is no iPhone 12 yet.
So I can use the iPhone Permax probably.
I'm just going to stay with this guy and within this new context, I'm going to use the syntax to set
the device, which is nothing but the iPhone device.
And I can also set the permission for the geolocation if I want to and stuff so I can set the permissions
geo locations.
And within this geolocation, I can set the latitude and longitude if I want to.
So like which location you are accessing this particular page and things of that nature, you can do
all sorts of things over here.
So I'm just going to do that and then I can set the clock and then I can add even more option over here.
But I'm not going to do all those things at the moment.
I'm just going to save this score.
And then if I try to run this card, I think I need to give a semicolon.
Sorry about that.
I saved it if I try to run this.
You can see that it's working fine, it's just opening the browser for me and automation, and then
you should open a browser, which is going to be more like a mobile view at the moment.
So this is really, really cool.
I mean, you can see what's really happening and how the browser is being launched for this particular
page.
So with this, it proves the point that you can also launch the same page on a different browser emulation
like device simulations and stuff, which is pretty cool.
So if I just stop this test and if I want to set the color theme of that particular page as maybe dark
or something like that, I can also do that if I want to.
So if I just save this and if I try to run that particular test once again so you can see that the page
opening is the automation and the Wikipedia should be open in the dark mode if it really supports that.
But looks like it doesn't really support the color scheme of data.
It's not been set for some reason.
So maybe that particular site doesn't really have that dark team and things of that nature.
That's why it's not working.
But anyways, it is actually working fine and this is what is the browser context is all about.
So this proves the point that it is working fine and nothing is really going wrong at the moment with
the browser context.
And this is really cool to see.
Browser contest are really helpful while you try to run like a multipage scenarios and stuff.
But as I said, we'll talk about select hours from our next lecture because pages is something that
we have already signed.
Like we know how the pages actually work because new pages are basically going to call the new tab and
everything is all right.
So I'm not going to talk about the pages at the moment.
But yes, this is all about the browser context.