1
00:00:00,120 --> 00:00:05,160
All right, so now we are actually going to see how we can intercept this particular server, which

2
00:00:05,160 --> 00:00:08,760
is we are which we are running and how we can change the data.

3
00:00:09,210 --> 00:00:17,310
So if you go to this particular site at the moment over here and if you just inspect that element and

4
00:00:17,310 --> 00:00:24,720
if you go to the probably that and if I tried to run this guy over here, you can see that our design

5
00:00:24,720 --> 00:00:27,910
is coming up with this particular response data.

6
00:00:27,960 --> 00:00:28,320
Yeah.

7
00:00:28,470 --> 00:00:34,680
And now our quest is to intercept this particular Devadas on data and need to change it to the way that

8
00:00:34,680 --> 00:00:35,230
we want it.

9
00:00:35,640 --> 00:00:40,560
I mean, this is the same thing that is applicable for many of the real time sites as well.

10
00:00:40,590 --> 00:00:43,500
Let's take my Web site automation dot com Web site.

11
00:00:43,860 --> 00:00:49,950
And if you just go to the inspect element and because there are so many data which is being loaded over

12
00:00:49,950 --> 00:00:55,770
here, there are many chances that these areas are actually coming from the debate or design file as

13
00:00:55,770 --> 00:00:55,950
well.

14
00:00:55,980 --> 00:01:01,170
So if I try to run this, you can see that there are so many data is being loaded.

15
00:01:01,470 --> 00:01:05,540
And if you go the extra mile, you can see there is something called a homepage.

16
00:01:05,860 --> 00:01:09,120
Is actually coming from an API data bundle off the homepage.

17
00:01:09,480 --> 00:01:11,420
And you can see this is the response coming in.

18
00:01:11,430 --> 00:01:17,580
So if you just preview it, you can see that the course learn part are the causes and all those details

19
00:01:17,580 --> 00:01:20,060
are actually coming from an API.

20
00:01:20,100 --> 00:01:23,010
So there is this a learning part over here.

21
00:01:23,280 --> 00:01:28,560
And you can see there is a cordless automation and there is a slug of UI.

22
00:01:28,560 --> 00:01:30,880
And this, of course, is on all these things.

23
00:01:30,930 --> 00:01:38,130
And similarly for the launchpad category, you can see UI APIs is all coming up over here like a design

24
00:01:38,130 --> 00:01:38,490
data.

25
00:01:38,520 --> 00:01:44,550
So this is how basically most of the sites renders the data or fetches the data and they render over

26
00:01:44,550 --> 00:01:45,600
here pretty quickly.

27
00:01:45,660 --> 00:01:48,060
So this is how it actually works on real time data as well.

28
00:01:48,900 --> 00:01:54,060
That's exactly what the idea is over here where we are going to intercept this request and modify it.

29
00:01:54,320 --> 00:01:55,440
You're going to ask me a question.

30
00:01:55,680 --> 00:02:00,330
Why can't you just directly do it on an existing mission website to probably change the data or that

31
00:02:00,330 --> 00:02:05,040
I can show you the reason why I can't do it directly on a site due to cause problem.

32
00:02:05,220 --> 00:02:12,000
But I could able to show you on this and then I can talk about the cards or cross origin in our next

33
00:02:12,000 --> 00:02:12,400
video.

34
00:02:12,600 --> 00:02:14,430
But in this lecture, just bear with me.

35
00:02:14,430 --> 00:02:20,070
This is how you can intercept at the moment so you can see that this guy is what I'm going to be intercepting

36
00:02:20,070 --> 00:02:24,000
and I want to see if I could able to intercept this request or not.

37
00:02:24,350 --> 00:02:29,520
In order to do that, I'm going to go back over here and to the network.

38
00:02:29,520 --> 00:02:31,590
I'm just going to create a new file.

39
00:02:31,650 --> 00:02:38,250
I'm going to call this as network intercept API server Darte Geass.

40
00:02:38,820 --> 00:02:43,910
And over here, I'm going to do exactly the same kind of code that we always try to do.

41
00:02:43,920 --> 00:02:45,420
So I'm just going to copy this.

42
00:02:45,420 --> 00:02:52,380
I'm going to pass it over here and I'm just gonna get rid of this mini DB because I'm going to do that

43
00:02:52,380 --> 00:02:52,920
at the moment.

44
00:02:53,790 --> 00:03:00,990
Just get rid of it and these things remain the same, but just that for this particular website, it

45
00:03:00,990 --> 00:03:03,350
is going to be your localhost.

46
00:03:03,960 --> 00:03:05,470
Three thousand probably.

47
00:03:05,520 --> 00:03:08,310
We are going to go to the post this guy.

48
00:03:09,270 --> 00:03:11,990
So I'm just going to change this to posts.

49
00:03:12,030 --> 00:03:14,610
That's it, that's the only thing I'm going to be doing.

50
00:03:15,060 --> 00:03:22,110
And for the road, once again, I'm actually going to go to this particular route directly or I can

51
00:03:22,110 --> 00:03:26,000
specify exactly which road I need to go so I can also filter that out.

52
00:03:26,010 --> 00:03:31,650
I mean, this time all this time, we have been using this asterisk, asterisk, assonance, which is

53
00:03:31,650 --> 00:03:32,810
nothing but the wildcard.

54
00:03:33,280 --> 00:03:34,650
We are finding the route.

55
00:03:34,860 --> 00:03:40,410
But this time I'm going to be very, very explicit and I'm telling that I need to go and intercept this

56
00:03:40,410 --> 00:03:47,790
DB off this particular site, which is nothing but this guy, that DB and on that particular DB, I

57
00:03:47,790 --> 00:03:50,860
need to intercept the request, which I am looking for.

58
00:03:51,270 --> 00:03:58,020
So the interception of the network is something which I'll be doing using one of the probably a mock

59
00:03:58,020 --> 00:03:59,280
response object.

60
00:03:59,280 --> 00:04:05,370
So I need to create a mock response object, which is something I will be using for intercepting.

61
00:04:05,700 --> 00:04:10,980
So I'm just going to put this picture on my response object over here and you can see that I'm going

62
00:04:10,980 --> 00:04:16,980
to be changing the title, something like a car takes over and a because I'm flattered or maybe even

63
00:04:16,980 --> 00:04:24,570
more meaningful, I can keep the title as end to end automation testing with playwright and author is

64
00:04:24,570 --> 00:04:26,970
going to be executed, automation or something like that.

65
00:04:27,180 --> 00:04:33,630
And even the comment I can change and the profile name can be naming that automation or something like

66
00:04:33,630 --> 00:04:33,770
that.

67
00:04:33,790 --> 00:04:34,360
That's all right.

68
00:04:34,920 --> 00:04:39,090
So this is the mark, the response object, which I really required this time.

69
00:04:39,090 --> 00:04:43,830
I need to put that response to be available for the intercepted request.

70
00:04:44,010 --> 00:04:48,480
And all the time we have been using this kind of code, just going to get rid of it.

71
00:04:48,630 --> 00:04:53,000
I will be using what is called as Routt Dart fulfillment third.

72
00:04:53,180 --> 00:04:56,820
So this is another method that I'm going to be using this time.

73
00:04:56,820 --> 00:04:59,070
So you may be wondering like, what the hell is this?

74
00:04:59,670 --> 00:05:04,560
This fullfillment, that is one which is going to slow the response for us.

75
00:05:04,560 --> 00:05:06,690
Like what response that you are looking for.

76
00:05:06,930 --> 00:05:12,120
So if you go to this particular fullfil method, like go to the definition, you can see you can set

77
00:05:12,120 --> 00:05:18,480
like status and headers, content types and bodies and paths and something like that.

78
00:05:19,080 --> 00:05:25,560
And so basically this fulfillment that is like and where that you can so a response for a particular

79
00:05:25,560 --> 00:05:26,120
request.

80
00:05:26,130 --> 00:05:27,520
So that's what you are going to be doing, right.

81
00:05:27,540 --> 00:05:32,680
I mean, you need to set your own response for this application to be responding for.

82
00:05:33,090 --> 00:05:37,730
So now I'm going to set the status probably two hundred, which is meaningful.

83
00:05:37,770 --> 00:05:39,330
So it is going to be correct as well.

84
00:05:39,660 --> 00:05:45,960
And I'm going to set the content type as application JSON.

85
00:05:46,330 --> 00:05:53,340
I prefer to have an intelligence here, but there is no such thing and I need to set the party so the

86
00:05:53,340 --> 00:05:57,560
body is what we need to set this particular JSON data.

87
00:05:58,080 --> 00:06:02,490
I mean, you can directly set this guy over like this.

88
00:06:02,490 --> 00:06:09,210
But what happens is because it's a JSON, you do somehow need to do a string yafai of a jasen so that

89
00:06:09,210 --> 00:06:10,560
it will be formatted correctly.

90
00:06:10,560 --> 00:06:14,550
So always try to do a string of AI to format things correctly.

91
00:06:15,240 --> 00:06:18,430
And this way the code is going to work as expected.

92
00:06:18,690 --> 00:06:19,150
That's it.

93
00:06:19,410 --> 00:06:26,640
This is the one thing that we need to do in order to make sure that this code is going to work fine

94
00:06:26,820 --> 00:06:27,660
as expected.

95
00:06:27,660 --> 00:06:29,310
So we'll see what is going to happen.

96
00:06:29,340 --> 00:06:34,620
Our response should be running this into an estimation of the playwright and author of Six Automation,

97
00:06:34,890 --> 00:06:37,160
but not sure about that if that works.

98
00:06:37,470 --> 00:06:40,890
So I'm just going to stop the test, which is running already.

99
00:06:41,370 --> 00:06:46,680
And I'm going it's going to do node of network intercept API.

100
00:06:46,680 --> 00:06:48,380
So we're just going to run this guy.

101
00:06:48,570 --> 00:06:51,360
I think this is just his GDP, not his GDP.

102
00:06:51,370 --> 00:06:51,850
Yes.

103
00:06:51,930 --> 00:06:55,620
Or because we put the his steps here that's aren't going to work.

104
00:06:55,920 --> 00:07:02,490
So I'm probably going to close this guy and let's change this to WP.

105
00:07:02,790 --> 00:07:06,000
And this is not w w w w well so I'm sorry about that.

106
00:07:06,480 --> 00:07:07,680
Just copy paste the code.

107
00:07:08,610 --> 00:07:09,030
All right.

108
00:07:09,030 --> 00:07:14,940
And now I'm just going to stop the test and let's try to run this again.

109
00:07:17,740 --> 00:07:24,520
There you go, you can see that it is still showing us the response as a response data, stateless playwright

110
00:07:24,520 --> 00:07:25,860
and author, a psychotic.

111
00:07:26,140 --> 00:07:34,660
But if you try to go to this particular site, maybe inspect element and if we try to.

112
00:07:35,910 --> 00:07:38,010
Run the console.

113
00:07:40,660 --> 00:07:48,550
Or the network, and if you go to the DB, you could actually see that the data which is being injected

114
00:07:48,550 --> 00:07:56,540
on this particular thing is actually passed as into test automation with playwright and author Associate

115
00:07:56,560 --> 00:08:01,050
Automation and the NamUs exhibit Automation or here.

116
00:08:01,060 --> 00:08:07,090
So basically the DB Dages on file is being intercepted, which is pretty cool.

117
00:08:07,120 --> 00:08:10,690
I mean, whatever we're trying to intercept at the moment is being intercepted.

118
00:08:10,930 --> 00:08:16,180
But just that if you try to do the post, what happens is this data on some of the fake designs or even

119
00:08:16,180 --> 00:08:22,690
though the data has been intercepted, it is not going to accept the developer design file, which is

120
00:08:22,690 --> 00:08:24,610
being injected over here.

121
00:08:24,610 --> 00:08:30,000
Rather, it is going to keep looking at the watch file that we have set on our earlier video.

122
00:08:30,010 --> 00:08:35,050
If you remember, we were actually setting the watch file over here like watch TV, Dages on file.

123
00:08:35,290 --> 00:08:37,980
So it is going to always watch that particular location.

124
00:08:38,320 --> 00:08:44,500
So that is the reason it is going to always look at this particular place where that data is there.

125
00:08:44,530 --> 00:08:51,010
So if I just even open the post, it is not looking at the injector data within the server because you

126
00:08:51,010 --> 00:08:52,840
know that this effect is on server.

127
00:08:52,850 --> 00:08:55,540
So I couldn't able to actually do that for us.

128
00:08:55,840 --> 00:09:01,960
So even if you try to not watch any of the data, it is going to be anyways intercept the same thing

129
00:09:01,960 --> 00:09:02,350
for us.

130
00:09:02,620 --> 00:09:09,400
So if you try to do something like a deep, dark jasen without the watch and if you try to run that,

131
00:09:09,670 --> 00:09:15,840
it is not going to do it for us because it couldn't be able to watch basically beyond the DVD on file.

132
00:09:15,850 --> 00:09:17,860
So it's going to always look for this file.

133
00:09:18,130 --> 00:09:19,590
But you got the idea right?

134
00:09:19,600 --> 00:09:26,260
I mean, this data that you already have on the server is being intercepted and the data has been injected

135
00:09:26,530 --> 00:09:28,060
with the one that you are looking for.

136
00:09:28,090 --> 00:09:34,180
So this way ensures that we are actually doing a mock interception at this particular point of time,

137
00:09:34,210 --> 00:09:34,900
which is pretty cool.

138
00:09:35,140 --> 00:09:40,050
In our next video, I'll show you why we can't really do the same kind of interception.

139
00:09:40,060 --> 00:09:43,180
But the real website, which is nothing but our automation website.
