1
00:00:00,210 --> 00:00:05,880
All right, hopefully you would have already figured out working with cookies, you would have set the

2
00:00:05,880 --> 00:00:06,350
cookies.

3
00:00:06,360 --> 00:00:10,590
If not, then I can tell you how I used to do the cooking settings and stuff.

4
00:00:10,900 --> 00:00:16,740
I mean, I do the most smartest way of doing with cookies because I don't really need to hand out all

5
00:00:16,740 --> 00:00:20,190
these cookie values and stuff because it is really, really hard for me to do it.

6
00:00:20,370 --> 00:00:26,010
And in playwrite, there are many other modern way of working with cookies because as I told, playwrite

7
00:00:26,010 --> 00:00:32,190
is a modern tool and they know all the pain points of a toaster or a developer who is going to do the

8
00:00:32,190 --> 00:00:35,850
testings and stuff so they know the better way of dealing with it.

9
00:00:36,150 --> 00:00:44,520
So what I'm going to do is I'm just going to go over here and I'm going to create a new folder probably

10
00:00:44,820 --> 00:00:47,970
here, create a folder called US Cookies.

11
00:00:49,140 --> 00:00:55,030
And within this file, I'm going to create something like Get Cookies, Dargis.

12
00:00:55,080 --> 00:01:02,650
So this get cookies is basically going to get a cookie for me from that particular website.

13
00:01:02,850 --> 00:01:09,000
So this way I could able to get the cookie informations and stuff, which is something I really require

14
00:01:09,000 --> 00:01:11,520
for my test to work with.

15
00:01:12,090 --> 00:01:17,940
So I'm just going to copy paste some of the code that we usually write, like launching the KRAMES and

16
00:01:17,940 --> 00:01:18,420
stuff.

17
00:01:18,420 --> 00:01:26,310
And this is exactly the same code that I just copy paste from our earlier sections of the course and

18
00:01:26,310 --> 00:01:30,660
I need to close the Arrow method and that's it.

19
00:01:30,690 --> 00:01:33,800
So this way, this is the normal code that we always used.

20
00:01:33,800 --> 00:01:34,040
Right.

21
00:01:34,440 --> 00:01:39,410
But we need to get the cookies information in order to get the cookie.

22
00:01:39,420 --> 00:01:43,920
There is a very, very easiest way that you can actually do, which is nothing.

23
00:01:43,920 --> 00:01:53,970
But let's say cookies, cookie is equal to a weight context, dot cookies.

24
00:01:54,330 --> 00:01:57,650
So this guy will actually return as the cookie.

25
00:01:57,660 --> 00:02:03,900
So this condescending but our browser context that we have set over here and this cookie, this browser

26
00:02:03,900 --> 00:02:07,100
contest actually has what is called cookies method.

27
00:02:07,410 --> 00:02:11,100
So this method is something responsible for getting the cookies for us.

28
00:02:11,460 --> 00:02:17,880
And now what I'm going to do is I'm just gonna do a cookie js on there.

29
00:02:17,880 --> 00:02:23,640
I'm just going to do JS on dot string if I as you know, that's the better way of doing it.

30
00:02:23,640 --> 00:02:30,320
And I'm just going to get a cookie over here and I'm going to deal with the files right now.

31
00:02:30,450 --> 00:02:37,710
So as you know, not only the files, I need a file system import which is required, and then I am

32
00:02:37,710 --> 00:02:42,950
going to be doing a writing of this particular cookie on a particular file.

33
00:02:42,960 --> 00:02:45,800
So I'm just going to do first start right files.

34
00:02:45,800 --> 00:02:55,350
Think of I'm going to call this as maybe Cookie or the Jasen and the cookie is going to be the cookie

35
00:02:55,350 --> 00:02:56,820
jar that we have got.

36
00:02:57,420 --> 00:02:58,040
That's it.

37
00:02:58,050 --> 00:03:03,080
So this way, all these Cookie Jason data is going to be written into this particular file for us.

38
00:03:03,360 --> 00:03:03,990
That's it.

39
00:03:04,020 --> 00:03:07,350
So once this is done, I can then close the browsers and stuff.

40
00:03:07,360 --> 00:03:09,170
So very, very simple.

41
00:03:09,360 --> 00:03:15,400
This way I could be able to get or obtain the cookie, which I really require write down.

42
00:03:15,450 --> 00:03:21,990
So see, this is really cool way to get the cookies instead of just spending so much of time to get

43
00:03:21,990 --> 00:03:23,820
the cookie information from outside.

44
00:03:23,970 --> 00:03:26,520
I mean, hand coding, all the details right from there.

45
00:03:26,760 --> 00:03:29,400
So I'm just going to run the.

46
00:03:30,880 --> 00:03:40,180
Test, so for that, I need to go to the cookie directly and then I'm going to just to nod off, I get

47
00:03:40,180 --> 00:03:42,310
cookies Dages on the Geass.

48
00:03:42,610 --> 00:03:47,800
So if I do that, this is going to generate a JSON file for me with all the cookie information.

49
00:03:48,500 --> 00:03:49,780
Uh, there you go.

50
00:03:49,990 --> 00:03:57,070
And you can see that I get a cookie information, so I'm just going to copy this and I can do a jasen

51
00:03:57,760 --> 00:04:04,780
formatter process that and you can see that I get a lot of information about that particular site.

52
00:04:04,780 --> 00:04:08,080
With all the cookie information, you can see that it's the same site.

53
00:04:08,090 --> 00:04:08,500
None.

54
00:04:08,890 --> 00:04:17,100
I request validation, verification, token, and there is this domain part expires hesitatingly secure.

55
00:04:17,320 --> 00:04:24,460
So these are the most important key that you really need to go on the site with for the cookie.

56
00:04:24,470 --> 00:04:29,290
So if you don't really give all those information, then this particular test is actually going to fail.

57
00:04:29,320 --> 00:04:33,550
So a cookie is something very, very important to have all these information.

58
00:04:33,580 --> 00:04:35,440
Do you see that within this cookie?

59
00:04:35,440 --> 00:04:43,540
I have to give name value, domain part expires, has to be only secured the same site and they have

60
00:04:43,540 --> 00:04:44,800
the lacson and then strict.

61
00:04:45,010 --> 00:04:47,920
This is the same thing that we are dealing with.

62
00:04:47,920 --> 00:04:51,310
These properties must be there within our cookie.

63
00:04:51,310 --> 00:04:57,030
And this is the cookie interface, which it actually expects at us for these data to be available.

64
00:04:57,190 --> 00:05:02,980
That's why I always go with the easiest and smartest way of doing just exploding the cookie information

65
00:05:03,220 --> 00:05:04,720
right from our site.

66
00:05:04,840 --> 00:05:06,220
And one of the cookie is being exported.

67
00:05:06,220 --> 00:05:11,380
I can then import this cookie and then I can run it in my test and see how it actually works.
