1
00:00:00,390 --> 00:00:04,800
So we have seen about the network interception and we saw how we can work with the network interception

2
00:00:04,800 --> 00:00:09,750
in a much detailed fashion, at least in terms of blocking few immense resources and stuff.

3
00:00:10,140 --> 00:00:16,380
But you also saw that while we tried to block one of the image or some of the images, the page was

4
00:00:16,380 --> 00:00:18,390
actually showing us a lot of exceptions.

5
00:00:18,630 --> 00:00:25,050
So we can actually capture those errors, which is coming on the Dowdle as well.

6
00:00:25,080 --> 00:00:31,650
So basically the chromed tools can show all the error messages which has been occurring on that particular

7
00:00:31,650 --> 00:00:32,000
page.

8
00:00:32,250 --> 00:00:38,850
So, for example, if we just go to the node of the network intercept or just if I tried to run this

9
00:00:38,850 --> 00:00:46,140
test once again and you can see that on this particular dev tool, if I just do an inspect.

10
00:00:47,270 --> 00:00:51,920
You can see that in the console, I get a lot of error messages saying the resources are not there or

11
00:00:51,920 --> 00:00:52,550
something like that.

12
00:00:52,790 --> 00:00:59,930
And finally, you can see that within this within this console, you can also see there are some messages

13
00:00:59,930 --> 00:01:08,180
related to the page crash, like some of the uncut exception, like light one M Amazon ember as a font

14
00:01:08,180 --> 00:01:08,960
is not there.

15
00:01:09,180 --> 00:01:13,370
And similarly, there are some exceptions like the resource, not phone or something like that.

16
00:01:13,670 --> 00:01:16,500
So these kind of exception messages you can grab as well.

17
00:01:16,520 --> 00:01:22,010
So there are situations like while we do our testing, some of the elements might not be loaded or some

18
00:01:22,010 --> 00:01:25,180
of the elements might be crashing and there will be some slight exceptions.

19
00:01:25,190 --> 00:01:32,070
So we need to somehow grab these exceptions like page event exceptions and crash at a message like request

20
00:01:32,100 --> 00:01:33,290
fail and things of that nature.

21
00:01:33,560 --> 00:01:39,950
In order to grab these informations, we have an option in playwrite to do that, which is really,

22
00:01:39,950 --> 00:01:40,930
really handy as well.

23
00:01:40,940 --> 00:01:45,590
And this is one of the modern way of testing in playwrite with the modern applications, because we

24
00:01:45,590 --> 00:01:50,300
need to know, because right now, while our website opens, there are so many different behind the

25
00:01:50,300 --> 00:01:51,910
scenes operations are happening.

26
00:01:51,920 --> 00:01:57,230
It's not just dumb content being ordered like image or Cyesis and things of that nature like discussed

27
00:01:57,230 --> 00:01:57,680
before.

28
00:01:57,680 --> 00:02:01,870
There are so many different architectural change happened in the Web applications right now.

29
00:02:02,150 --> 00:02:10,270
So in order for grabbing all those events, we can actually do something like get page events start.

30
00:02:10,400 --> 00:02:12,830
Yes, I'm just going to write a call, something like this.

31
00:02:13,160 --> 00:02:16,340
I'm just going to copy paste the exact same code over here.

32
00:02:16,730 --> 00:02:23,000
And just that after this page has been loaded up, I'm actually going to write a code which is going

33
00:02:23,000 --> 00:02:26,680
to be using a method called as on method.

34
00:02:27,020 --> 00:02:32,300
So if I remember in our last lecture we were talking about the root method surrounding provides the

35
00:02:32,300 --> 00:02:35,780
capability to modify the network request that are made by a page.

36
00:02:35,780 --> 00:02:42,800
Once the routing is enabled, every request matching that your pattern will stall unless it is continually

37
00:02:42,800 --> 00:02:44,320
fulfilled or aborted.

38
00:02:44,690 --> 00:02:46,100
So this is what we did.

39
00:02:46,100 --> 00:02:53,180
I mean, if we intercept this particular network request and if it is of resource type estimate, then

40
00:02:53,180 --> 00:02:55,750
we set about the request, if not just continue.

41
00:02:55,760 --> 00:03:02,150
So we are intercepting the network at this point, but using the old method, we are going to be verifying

42
00:03:02,390 --> 00:03:10,760
different events or errors the page can actually emit while the process of execution or the loading

43
00:03:10,760 --> 00:03:11,910
of a page actually happens.

44
00:03:11,930 --> 00:03:16,430
So I'm actually going to open that process over here and you can see that it's going to tell me that

45
00:03:16,430 --> 00:03:18,190
there is an event like close event.

46
00:03:18,200 --> 00:03:23,030
So if I just put a single code here, you can see that it's going to show you all the different event

47
00:03:23,360 --> 00:03:27,850
currently supported by playwrite and also by the DOM pages.

48
00:03:28,040 --> 00:03:33,500
So you can see that there's a closed event, console, event, crash event dialogues just to handle

49
00:03:33,500 --> 00:03:36,200
the dialog box like pop up and things of that nature.

50
00:03:36,530 --> 00:03:42,740
And similarly, the download is the download operation that you can do file Tuzer frame attached, load

51
00:03:42,740 --> 00:03:45,060
event page errors, popup window.

52
00:03:45,080 --> 00:03:48,500
So this is for the purpose of Windows basically and for the request.

53
00:03:48,980 --> 00:03:52,910
So this request is something like how we did earlier over here, same kind of thing.

54
00:03:53,150 --> 00:03:59,960
And I just feel like I just finished and responds websocket and workers and things so you can do a lot

55
00:03:59,960 --> 00:04:00,910
of different operation.

56
00:04:00,920 --> 00:04:04,340
I mean, these are the cool things that you can do with the playwright right at the moment.

57
00:04:04,680 --> 00:04:08,780
So I'm just going to use the, let's say, the page error there.

58
00:04:08,780 --> 00:04:18,050
I'm going to write something like an page error where I'm going to tell that just output me all the

59
00:04:18,050 --> 00:04:21,830
log errors of that particular page, like the current phase that I have.

60
00:04:22,160 --> 00:04:26,200
And tell me what are the errors which is happening at the moment on the particular page.

61
00:04:26,630 --> 00:04:29,390
And so I'm just going to see page errors.

62
00:04:30,230 --> 00:04:35,090
And now if I try to grab this picture page error, you're going to see all the page errors, which is

63
00:04:35,090 --> 00:04:37,040
going to be occurring on that particular page.

64
00:04:37,450 --> 00:04:45,570
I'm just going to stop this guy and I'm going to run the get a page, even Dargis.

65
00:04:45,600 --> 00:04:46,550
I'm just going to execute it.

66
00:04:47,690 --> 00:04:53,390
You can see that it's currently running the test for us at the same time, it's going to show us all

67
00:04:53,390 --> 00:04:57,500
the error messages that we were actually seeing on the console before.

68
00:04:57,960 --> 00:05:03,610
So it just shows me all the error, just a page errors, but it's not going to show me all the resource

69
00:05:03,980 --> 00:05:04,320
errors.

70
00:05:04,340 --> 00:05:04,460
And.

71
00:05:04,730 --> 00:05:11,060
And then if we want to try how we can get the other errors that we were actually getting on the page

72
00:05:11,060 --> 00:05:16,340
while it was loading, like the image is not loader or something like that, we can actually try doing

73
00:05:16,910 --> 00:05:18,080
something like a.

74
00:05:19,120 --> 00:05:24,040
Request filed exceptions and things of that nature, so it's going to be pretty much exactly the same

75
00:05:24,040 --> 00:05:25,620
kind of court you can actually use.

76
00:05:25,660 --> 00:05:31,780
So I'm just going to copy paste this code and here I'm just going to call this as I just do something

77
00:05:31,780 --> 00:05:32,260
like this.

78
00:05:32,260 --> 00:05:34,330
You can see there is something called a request failed.

79
00:05:34,840 --> 00:05:41,080
And I can probably change this to request failed or something like that.

80
00:05:41,590 --> 00:05:43,800
And we can put it all here.

81
00:05:44,230 --> 00:05:45,430
Request error.

82
00:05:48,100 --> 00:05:53,170
I'm just going to say this, and now if I try to run this guy, you will see that that is going to be

83
00:05:53,170 --> 00:05:56,620
a lot of errors related to the image not being lauded.

84
00:05:56,980 --> 00:05:59,940
So you can see that we have intercepted all the image not being loaded.

85
00:05:59,950 --> 00:06:01,540
So it is going to show all those things.

86
00:06:01,780 --> 00:06:08,320
But currently it is showing us like an object because we are not resolving that using its Yarl's.

87
00:06:08,740 --> 00:06:10,840
So probably just going to stop this guy.

88
00:06:11,300 --> 00:06:20,830
And if I just call a method called us Yoro, because the method actually is going to show you all the

89
00:06:21,370 --> 00:06:22,040
errors.

90
00:06:22,110 --> 00:06:24,010
It's not on this one.

91
00:06:26,200 --> 00:06:33,940
But on this one, so you can see that the intelligence is coming up, just going to with this guy,

92
00:06:34,250 --> 00:06:40,880
and if I try to run, this is going to show you exactly what errors the page was actually encountering.

93
00:06:41,020 --> 00:06:45,970
You can see all these images are not being loaded and it is trying to still listen, like, what are

94
00:06:45,970 --> 00:06:49,480
the images which are not the resources not being loaded and things.

95
00:06:49,840 --> 00:06:54,310
So if you try to refresh this page right now, you can see that the errors are still being intercepted

96
00:06:54,580 --> 00:06:58,210
behind the scenes and tell me that these images are not being loaded.

97
00:06:59,230 --> 00:07:00,620
And this is a request error.

98
00:07:00,850 --> 00:07:02,020
So this is cool, right?

99
00:07:02,040 --> 00:07:09,340
I mean, you can try to get all the different dev tools, console, log directly in your playwrite.

100
00:07:09,340 --> 00:07:15,070
And these are something that we can use for our automation testing to verify if there is a new release

101
00:07:15,070 --> 00:07:15,550
happening.

102
00:07:16,030 --> 00:07:20,740
Is there any issue just on the behind the scene of our page?

103
00:07:21,190 --> 00:07:25,630
Pretty quickly, we can grab that and we can show these error messages to the developer so that they

104
00:07:25,630 --> 00:07:32,590
will know what's happening behind the scenes, like any adaptor error or maybe any API errors that is

105
00:07:32,590 --> 00:07:33,820
happening on our page.

106
00:07:33,850 --> 00:07:37,900
So this is another way, our modern way of doing testing in playwrite.
