So we have seen about the network interception and we saw how we can work with the network interception
in a much detailed fashion, at least in terms of blocking few immense resources and stuff.
But you also saw that while we tried to block one of the image or some of the images, the page was
actually showing us a lot of exceptions.
So we can actually capture those errors, which is coming on the Dowdle as well.
So basically the chromed tools can show all the error messages which has been occurring on that particular
page.
So, for example, if we just go to the node of the network intercept or just if I tried to run this
test once again and you can see that on this particular dev tool, if I just do an inspect.
You can see that in the console, I get a lot of error messages saying the resources are not there or
something like that.
And finally, you can see that within this within this console, you can also see there are some messages
related to the page crash, like some of the uncut exception, like light one M Amazon ember as a font
is not there.
And similarly, there are some exceptions like the resource, not phone or something like that.
So these kind of exception messages you can grab as well.
So there are situations like while we do our testing, some of the elements might not be loaded or some
of the elements might be crashing and there will be some slight exceptions.
So we need to somehow grab these exceptions like page event exceptions and crash at a message like request
fail and things of that nature.
In order to grab these informations, we have an option in playwrite to do that, which is really,
really handy as well.
And this is one of the modern way of testing in playwrite with the modern applications, because we
need to know, because right now, while our website opens, there are so many different behind the
scenes operations are happening.
It's not just dumb content being ordered like image or Cyesis and things of that nature like discussed
before.
There are so many different architectural change happened in the Web applications right now.
So in order for grabbing all those events, we can actually do something like get page events start.
Yes, I'm just going to write a call, something like this.
I'm just going to copy paste the exact same code over here.
And just that after this page has been loaded up, I'm actually going to write a code which is going
to be using a method called as on method.
So if I remember in our last lecture we were talking about the root method surrounding provides the
capability to modify the network request that are made by a page.
Once the routing is enabled, every request matching that your pattern will stall unless it is continually
fulfilled or aborted.
So this is what we did.
I mean, if we intercept this particular network request and if it is of resource type estimate, then
we set about the request, if not just continue.
So we are intercepting the network at this point, but using the old method, we are going to be verifying
different events or errors the page can actually emit while the process of execution or the loading
of a page actually happens.
So I'm actually going to open that process over here and you can see that it's going to tell me that
there is an event like close event.
So if I just put a single code here, you can see that it's going to show you all the different event
currently supported by playwrite and also by the DOM pages.
So you can see that there's a closed event, console, event, crash event dialogues just to handle
the dialog box like pop up and things of that nature.
And similarly, the download is the download operation that you can do file Tuzer frame attached, load
event page errors, popup window.
So this is for the purpose of Windows basically and for the request.
So this request is something like how we did earlier over here, same kind of thing.
And I just feel like I just finished and responds websocket and workers and things so you can do a lot
of different operation.
I mean, these are the cool things that you can do with the playwright right at the moment.
So I'm just going to use the, let's say, the page error there.
I'm going to write something like an page error where I'm going to tell that just output me all the
log errors of that particular page, like the current phase that I have.
And tell me what are the errors which is happening at the moment on the particular page.
And so I'm just going to see page errors.
And now if I try to grab this picture page error, you're going to see all the page errors, which is
going to be occurring on that particular page.
I'm just going to stop this guy and I'm going to run the get a page, even Dargis.
I'm just going to execute it.
You can see that it's currently running the test for us at the same time, it's going to show us all
the error messages that we were actually seeing on the console before.
So it just shows me all the error, just a page errors, but it's not going to show me all the resource
errors.
And.
And then if we want to try how we can get the other errors that we were actually getting on the page
while it was loading, like the image is not loader or something like that, we can actually try doing
something like a.
Request filed exceptions and things of that nature, so it's going to be pretty much exactly the same
kind of court you can actually use.
So I'm just going to copy paste this code and here I'm just going to call this as I just do something
like this.
You can see there is something called a request failed.
And I can probably change this to request failed or something like that.
And we can put it all here.
Request error.
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
a lot of errors related to the image not being lauded.
So you can see that we have intercepted all the image not being loaded.
So it is going to show all those things.
But currently it is showing us like an object because we are not resolving that using its Yarl's.
So probably just going to stop this guy.
And if I just call a method called us Yoro, because the method actually is going to show you all the
errors.
It's not on this one.
But on this one, so you can see that the intelligence is coming up, just going to with this guy,
and if I try to run, this is going to show you exactly what errors the page was actually encountering.
You can see all these images are not being loaded and it is trying to still listen, like, what are
the images which are not the resources not being loaded and things.
So if you try to refresh this page right now, you can see that the errors are still being intercepted
behind the scenes and tell me that these images are not being loaded.
And this is a request error.
So this is cool, right?
I mean, you can try to get all the different dev tools, console, log directly in your playwrite.
And these are something that we can use for our automation testing to verify if there is a new release
happening.
Is there any issue just on the behind the scene of our page?
Pretty quickly, we can grab that and we can show these error messages to the developer so that they
will know what's happening behind the scenes, like any adaptor error or maybe any API errors that is
happening on our page.
So this is another way, our modern way of doing testing in playwrite.