1
00:00:00,300 --> 00:00:07,110
All right, so now that we already have our cookies in this particular Jason file, we can just use

2
00:00:07,110 --> 00:00:15,060
this same Jason file and we can able to set the cookie information on our test and we can see how it

3
00:00:15,060 --> 00:00:15,770
actually works.

4
00:00:15,780 --> 00:00:24,120
So far doing that, I'm just going to create one more file called call this as cookie or maybe a cookie

5
00:00:25,070 --> 00:00:25,330
jar.

6
00:00:26,490 --> 00:00:26,970
Yes.

7
00:00:28,320 --> 00:00:33,790
And this guy is going to hold the same sort of test, probably, uh, like get cookies.

8
00:00:34,140 --> 00:00:39,210
I don't really have to go deal everything, but just copy paste on the court from here.

9
00:00:39,630 --> 00:00:45,000
And I'm just going to get rid of all these courts because all I'm going to do is I'm just going to navigate

10
00:00:45,000 --> 00:00:48,990
directly to that particular website to create an.

11
00:00:50,560 --> 00:00:56,890
Employee create page, and I need to see if that really works or not without logging in and stuff,

12
00:00:56,890 --> 00:01:00,910
so I'm not going to do any of these informations or here.

13
00:01:01,150 --> 00:01:03,890
I'm just going to use a cookie and we'll see how it actually works.

14
00:01:04,360 --> 00:01:07,470
So far, doing that, as you can see, I have already done the code.

15
00:01:07,480 --> 00:01:10,290
I have a commentary to even my earlier lecture.

16
00:01:10,480 --> 00:01:14,260
I have to call this method, called us the cookie on the context.

17
00:01:14,260 --> 00:01:16,860
And then I need to add a cookie over here.

18
00:01:17,140 --> 00:01:20,890
I can do this cookie directly using this particular Jasen file.

19
00:01:20,890 --> 00:01:27,010
I can just put all the value in my file and then I can do it, or I can just try to read the file and

20
00:01:27,010 --> 00:01:30,400
then I can set the particular value on this particular add cookie.

21
00:01:30,730 --> 00:01:34,660
So what I'm going to do is I'm just going to do this cookie.

22
00:01:36,040 --> 00:01:38,990
Is equal to John Dot String.

23
00:01:39,020 --> 00:01:44,290
If I was, I always try to do and then first dot read file sync.

24
00:01:46,890 --> 00:01:48,630
Of slash.

25
00:01:51,350 --> 00:01:54,280
The cookies.

26
00:01:57,390 --> 00:01:59,260
Jason, I think, is equally Keidar Jason.

27
00:01:59,300 --> 00:02:06,850
Yeah, and the format is going to be the UTF eight as well.

28
00:02:07,960 --> 00:02:14,680
That's it, and this cookie is something we are going to add over here, so this way it's going to add

29
00:02:14,680 --> 00:02:17,430
all the cookie information for us, which is quite good.

30
00:02:17,830 --> 00:02:26,140
And now if I try to navigate directly to the particular website that do on the create website, I should

31
00:02:26,140 --> 00:02:29,670
see the site being already logged in instead of logged outstate.

32
00:02:29,980 --> 00:02:31,830
So we'll see how it actually works.

33
00:02:31,870 --> 00:02:35,830
Um, actually based this particular URL instead of the.

34
00:02:36,960 --> 00:02:45,330
Employee login, so I'm not even going to login this time, I'm just going to do a cookie information

35
00:02:45,330 --> 00:02:49,430
and then I'm going to pass the cookie information and then I'm going to do a create operation.

36
00:02:49,470 --> 00:02:50,770
So we'll see how it actually works.

37
00:02:51,150 --> 00:02:52,140
So, node.

38
00:02:54,190 --> 00:02:59,480
Eat a cookie, Dargis, oops, I'm also getting some error here.

39
00:02:59,810 --> 00:03:03,740
Uh, says that the cookie expected array and got a string.

40
00:03:04,400 --> 00:03:07,410
Um, I think I messed up somewhere on the call.

41
00:03:07,520 --> 00:03:07,850
Yeah.

42
00:03:07,850 --> 00:03:13,190
I think this Jasanoff, a string yafai is not right because the string yafai is going to convert the

43
00:03:13,190 --> 00:03:14,000
jasen.

44
00:03:15,500 --> 00:03:22,250
Value to end string, but this guy, the ad, Kyuki, always expect an array if I'm not wrong, as you

45
00:03:22,250 --> 00:03:24,520
can see over here, this is expecting for an array.

46
00:03:24,860 --> 00:03:27,280
So we need to somehow get the array over here.

47
00:03:27,410 --> 00:03:33,710
So what we should do is instead of Jasanoff string, if there is a method called as POS, which is going

48
00:03:33,710 --> 00:03:38,130
to do a part of the operation for us and will do things for us, much, much easier.

49
00:03:38,660 --> 00:03:43,550
So I'm just going to stop this guy and I'm probably going to save it right now.

50
00:03:43,850 --> 00:03:50,870
And if I try to run the year kookie, I'm definitely sure that this is going to work fine.

51
00:03:51,460 --> 00:03:53,210
I'm sorry it's not been saved.

52
00:03:53,480 --> 00:03:54,350
Sorry about that.

53
00:03:55,080 --> 00:04:00,110
So I'm just going to save it and stop the test on it again.

54
00:04:01,440 --> 00:04:08,030
So you can see that the browser is not opening and you can see that our site is now logged in, guys,

55
00:04:08,040 --> 00:04:13,560
you can see that this guy is going to show us the employee information employee details employee list.

56
00:04:13,780 --> 00:04:17,280
And that is a create new as well as I could able to easily create.

57
00:04:17,520 --> 00:04:20,540
And this guy is actually logged in, which is quite good.

58
00:04:20,550 --> 00:04:20,970
So that.

59
00:04:22,040 --> 00:04:23,100
Sensitive information.

60
00:04:23,360 --> 00:04:31,640
So the information that I have is actually correct over here, so if I go to the application, you could

61
00:04:31,640 --> 00:04:34,310
see that I have the cookie over here.

62
00:04:34,550 --> 00:04:41,480
These values are actually set from our cookies that we have passed over the cookies on the jasen file

63
00:04:41,480 --> 00:04:44,190
that we have over here, which is quite good.

64
00:04:44,210 --> 00:04:51,270
So this way, we could be able to ensure that we could be able to set cookies on our website and we

65
00:04:51,270 --> 00:04:56,020
could be able to log in without actually logging in and perform all the operations.

66
00:04:56,030 --> 00:05:01,880
So this way is very, very handy because I got this I get some questions from the audience asking how

67
00:05:01,880 --> 00:05:09,560
I can actually log into a website which actually has a Microsoft authenticator or a Microsoft logging

68
00:05:09,560 --> 00:05:10,160
operation.

69
00:05:10,370 --> 00:05:12,770
So you can actually get those cookies information.

70
00:05:12,770 --> 00:05:18,320
You can directly set the cookie information on your website and then you can bypass the logging operation

71
00:05:18,320 --> 00:05:23,890
and then you can directly get into the site instead of you being sitting all the cookie information.

72
00:05:23,900 --> 00:05:26,640
So this way you can reduce the fragile code as well.

73
00:05:26,660 --> 00:05:28,910
You don't really have to log in each and every time.

74
00:05:29,140 --> 00:05:32,250
Rather, you can just set the cookie and then you can log in from there.

75
00:05:32,300 --> 00:05:38,600
This way you save enormous amount of time of being logging every time and then performing the operation.

76
00:05:39,050 --> 00:05:40,860
This saves a lot of time as well.

77
00:05:40,880 --> 00:05:46,520
So this is another better way of dealing with your coding instead of logging in each and every time.

78
00:05:46,990 --> 00:05:53,330
Lot of guys, this how we can actually deliver the cookies and this is how we can modernize our automation

79
00:05:53,720 --> 00:05:54,550
in playwrite.

80
00:05:54,680 --> 00:06:00,200
I think this Hands-On lab is giving even more information of modernizing work test automation a level

81
00:06:00,200 --> 00:06:00,620
further.
