1
00:00:00,150 --> 00:00:04,320
So don't ask, we do have a discussion about Browsr a lot, and in this video we can talk about broader

2
00:00:04,320 --> 00:00:10,110
context if remember what we tried to do, a recording and playback of the with the playwright Seelie,

3
00:00:10,260 --> 00:00:14,690
we saw the code automatically generated the browser, the new context.

4
00:00:14,700 --> 00:00:19,710
So this new context, as I told you, is like a browser context, which is responsible for creating

5
00:00:19,710 --> 00:00:21,410
a lightweight context, basically.

6
00:00:21,660 --> 00:00:27,120
So if you don't really see this in action, you can actually see this in a more meaningful and more

7
00:00:27,120 --> 00:00:27,930
easier way.

8
00:00:28,230 --> 00:00:34,740
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

9
00:00:34,740 --> 00:00:37,860
to something like that.

10
00:00:38,020 --> 00:00:43,440
I might use the same browser as you can see the browser of new context, but I'm using context to over

11
00:00:43,440 --> 00:00:45,570
here in this context, too.

12
00:00:45,750 --> 00:00:48,100
I'm going to create a new page as well.

13
00:00:48,210 --> 00:00:51,060
So I'm just going to keep all these things as it is.

14
00:00:51,540 --> 00:00:58,770
Um, well, copy paste, this is going to be a page to confess to.

15
00:00:59,130 --> 00:01:06,650
And within page two, I'm going to be navigating to let's call it automation dot com and I'm going to

16
00:01:06,650 --> 00:01:08,190
take a screenshot or something like that.

17
00:01:08,490 --> 00:01:08,860
Yeah.

18
00:01:09,210 --> 00:01:12,850
So this is a different context and this is going to be a separate contest altogether.

19
00:01:12,870 --> 00:01:13,860
I'm just going to save this.

20
00:01:14,190 --> 00:01:17,700
And now if I try to run this court, you will see what's going to happen.

21
00:01:17,730 --> 00:01:21,720
So the first time it launches the browser, it took some time to launch.

22
00:01:21,990 --> 00:01:26,520
I mean, you don't really see the difference between both of them, but you can see that once the test

23
00:01:26,520 --> 00:01:32,220
is fully executed, it is going to open another browser, which is quite faster, actually.

24
00:01:32,250 --> 00:01:36,030
I mean, we don't really see those two difference at the moment.

25
00:01:36,180 --> 00:01:38,250
But, yes, there are a difference.

26
00:01:38,260 --> 00:01:43,890
So if I just close this test, probably the Firefox was quite slow in my machine, so I'm just going

27
00:01:43,890 --> 00:01:45,380
to go remotely slow.

28
00:01:46,890 --> 00:01:49,560
I'm just going to say this.

29
00:01:49,830 --> 00:01:52,710
Let's change this to Firefox.

30
00:01:53,280 --> 00:01:54,990
I think that was literally visible.

31
00:01:55,260 --> 00:02:00,750
I'm just going to copy this pasted over here and I'm going to run them now.

32
00:02:03,950 --> 00:02:07,430
So you can see that it took some time actually to launch the browser.

33
00:02:08,580 --> 00:02:11,560
And you can see that this guy is launching pretty faster as well.

34
00:02:12,300 --> 00:02:17,550
So it shows the point that you are actually using a different context altogether and they don't really

35
00:02:17,550 --> 00:02:18,560
talk with each other.

36
00:02:18,570 --> 00:02:24,810
So this context, a context, too, has no relation with context itself.

37
00:02:24,840 --> 00:02:31,920
So if this context has got any logging operation done for, let's say, a Wikipedia page, then the

38
00:02:31,920 --> 00:02:37,140
context to which is going with a net zero automation page has got no relation with it.

39
00:02:37,290 --> 00:02:43,080
And it won't even care like what cookies and stuff are there, because browser context is basically

40
00:02:43,110 --> 00:02:47,580
like an incognito operation, which you are doing while you perform any operation.

41
00:02:47,820 --> 00:02:52,500
It's also a good practice that once you're done with executing, you should close that particular context

42
00:02:52,500 --> 00:02:52,900
as well.

43
00:02:52,920 --> 00:02:55,680
So that is one of the another important thing that you should be doing.

44
00:02:56,040 --> 00:03:03,150
And within this new context, you can also do a different set of operations, like you can set the permissions

45
00:03:03,390 --> 00:03:05,720
and then you can set the geolocation and stuff.

46
00:03:06,000 --> 00:03:12,180
So if you say within this particular context, let's say if I want to open this context, something

47
00:03:12,180 --> 00:03:19,020
like this, and if it lets let's say if I just go to the definition of this new context, you can see

48
00:03:19,020 --> 00:03:21,520
there is something called a browser context option.

49
00:03:21,540 --> 00:03:23,190
So let me go here.

50
00:03:23,350 --> 00:03:25,340
There is something called the browser context option.

51
00:03:26,130 --> 00:03:32,680
So if I go to the browser Kandace option interface, you can see it says except downloads ignore has

52
00:03:33,150 --> 00:03:42,650
errors bypass kesby viewport, user agent device scale factors has touch times on ID, geolocation,

53
00:03:43,050 --> 00:03:48,810
local permissions, extra hacerte beheaders, offline color schemes, video part.

54
00:03:48,810 --> 00:03:50,870
I mean we are not even talked about really about yet.

55
00:03:51,090 --> 00:03:52,140
We talk about that later.

56
00:03:52,350 --> 00:03:53,970
But yes, you can do that.

57
00:03:53,970 --> 00:03:59,610
And similar regard, the hard file which is going to be your whole analytics transactions and stuff

58
00:03:59,610 --> 00:04:07,110
like FSR transactions and then record with what is the different properties that its director going

59
00:04:07,110 --> 00:04:11,490
to stay on, things proxy's storage, dead and stuff.

60
00:04:11,490 --> 00:04:15,140
So you can do a lot of things with this particular context alone.

61
00:04:15,510 --> 00:04:21,810
So it's quite different from the browser launch option because the browser context option is different

62
00:04:21,810 --> 00:04:25,710
from the launch option completely because this is a different context altogether.

63
00:04:26,070 --> 00:04:32,670
But here we can also do some sort of manipulations of the browsers, like because it has the device

64
00:04:32,910 --> 00:04:34,470
context that you can also do that.

65
00:04:34,650 --> 00:04:41,070
So if you don't really get what I mean, how did we change this to chrome game like chromium over here?

66
00:04:41,640 --> 00:04:43,360
And I'm going to call.

67
00:04:44,130 --> 00:04:48,960
So if you go to this particular constant, you can see that we have something called US Devices Constant,

68
00:04:49,290 --> 00:04:53,750
which is responsible for all the devices and devices descriptors.

69
00:04:53,760 --> 00:04:56,730
So this is very, very helpful while you work with the different devices.

70
00:04:56,740 --> 00:05:01,800
So if you go to the device descriptors, you can see that are different device descriptors are available

71
00:05:01,800 --> 00:05:11,370
like viewport strings of user agent device scale factors is mobile, has touch and defined mobile browser

72
00:05:11,380 --> 00:05:11,800
and stuff.

73
00:05:12,150 --> 00:05:13,440
So this is very, very handy.

74
00:05:13,440 --> 00:05:17,040
When you work with those particular devices, you can set all those things.

75
00:05:17,400 --> 00:05:20,360
And I'm also going to do one more thing in here.

76
00:05:20,400 --> 00:05:28,320
I'm just going to set constant of iPhone Zolta devices off.

77
00:05:28,650 --> 00:05:33,240
Once I hit Colline, it automatically brings all the device properties for me.

78
00:05:33,270 --> 00:05:36,750
So let's say I want to use my iPhone.

79
00:05:37,650 --> 00:05:39,330
So there is no iPhone 12 yet.

80
00:05:39,720 --> 00:05:42,060
So I can use the iPhone Permax probably.

81
00:05:43,040 --> 00:05:50,360
I'm just going to stay with this guy and within this new context, I'm going to use the syntax to set

82
00:05:50,570 --> 00:05:53,510
the device, which is nothing but the iPhone device.

83
00:05:54,020 --> 00:06:04,760
And I can also set the permission for the geolocation if I want to and stuff so I can set the permissions

84
00:06:05,030 --> 00:06:06,470
geo locations.

85
00:06:06,590 --> 00:06:12,820
And within this geolocation, I can set the latitude and longitude if I want to.

86
00:06:12,830 --> 00:06:18,650
So like which location you are accessing this particular page and things of that nature, you can do

87
00:06:18,650 --> 00:06:19,960
all sorts of things over here.

88
00:06:20,330 --> 00:06:28,340
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.

89
00:06:28,340 --> 00:06:30,410
But I'm not going to do all those things at the moment.

90
00:06:30,740 --> 00:06:31,970
I'm just going to save this score.

91
00:06:32,240 --> 00:06:36,170
And then if I try to run this card, I think I need to give a semicolon.

92
00:06:36,170 --> 00:06:37,100
Sorry about that.

93
00:06:37,280 --> 00:06:39,890
I saved it if I try to run this.

94
00:06:41,400 --> 00:06:45,780
You can see that it's working fine, it's just opening the browser for me and automation, and then

95
00:06:45,780 --> 00:06:50,200
you should open a browser, which is going to be more like a mobile view at the moment.

96
00:06:50,220 --> 00:06:51,760
So this is really, really cool.

97
00:06:51,780 --> 00:06:57,330
I mean, you can see what's really happening and how the browser is being launched for this particular

98
00:06:57,780 --> 00:06:58,260
page.

99
00:06:58,530 --> 00:07:04,260
So with this, it proves the point that you can also launch the same page on a different browser emulation

100
00:07:04,260 --> 00:07:06,750
like device simulations and stuff, which is pretty cool.

101
00:07:07,140 --> 00:07:15,540
So if I just stop this test and if I want to set the color theme of that particular page as maybe dark

102
00:07:15,540 --> 00:07:18,220
or something like that, I can also do that if I want to.

103
00:07:18,240 --> 00:07:25,200
So if I just save this and if I try to run that particular test once again so you can see that the page

104
00:07:25,200 --> 00:07:30,900
opening is the automation and the Wikipedia should be open in the dark mode if it really supports that.

105
00:07:31,200 --> 00:07:35,270
But looks like it doesn't really support the color scheme of data.

106
00:07:35,310 --> 00:07:36,890
It's not been set for some reason.

107
00:07:36,900 --> 00:07:41,920
So maybe that particular site doesn't really have that dark team and things of that nature.

108
00:07:41,970 --> 00:07:43,050
That's why it's not working.

109
00:07:43,320 --> 00:07:47,680
But anyways, it is actually working fine and this is what is the browser context is all about.

110
00:07:47,970 --> 00:07:52,920
So this proves the point that it is working fine and nothing is really going wrong at the moment with

111
00:07:52,920 --> 00:07:53,880
the browser context.

112
00:07:53,880 --> 00:07:55,560
And this is really cool to see.

113
00:07:55,800 --> 00:08:00,540
Browser contest are really helpful while you try to run like a multipage scenarios and stuff.

114
00:08:01,060 --> 00:08:07,410
But as I said, we'll talk about select hours from our next lecture because pages is something that

115
00:08:07,410 --> 00:08:09,050
we have already signed.

116
00:08:09,140 --> 00:08:14,220
Like we know how the pages actually work because new pages are basically going to call the new tab and

117
00:08:14,220 --> 00:08:15,210
everything is all right.

118
00:08:15,220 --> 00:08:17,580
So I'm not going to talk about the pages at the moment.

119
00:08:17,790 --> 00:08:19,860
But yes, this is all about the browser context.
