In today’s newsletter we are going to discuss
What is Chrome DevTools ?
Monitoring HTTP Requests
Intercepting HTTP Responses
Blocked URLs
Load Insecure sites
What is Chrome DevTools?
Selenium 4 has added native support for Chrome DevTools. Chrome DevTools is a debugging tools built directly into the Google Chrome browser.
It provides developers with a comprehensive suite of tools for inspecting, debugging, profiling, and optimizing web applications.
Monitoring HTTP Requests
HTTP Requests can be monitored in Selenium 4 using Dev Tools.
We can use various network events such as 'requestWillBeSent', 'responseReceived' to capture details about HTTP requests and responses.
Here are the list of things we can monitor on HTTP Request:
1. Request Method
2. Request URL
3. Request Headers
4. Request BodyLet’s see some sample code:
And here is the video of the output
Intercepting HTTP Responses
To intercept the response we will be using Network.responseReceived event.
This event will fire when the HTTP response is available.
Here are the response parameters we can listen to :
- URL
- response headers
- response code
Let’s see some sample code:
And here is the video of the output
Blocked URLs
We can block certain URLs from loading while the webpage loads.
This can be useful for testing scenarios where you want to simulate the absence of certain resources or external services.
Let’s see some sample code:
And here is the video of the output
Load Insecure sites
Loading insecure (HTTP) sites in Selenium can be useful for testing scenarios where you want to interact with websites that don't have valid SSL certificates.
With DevTools we can ignore SSL Security warnings.
Sometimes we have seen this image while browsing something.
We can ignore above page and directly navigate to the URL by using below code.
Let’s see some sample code:
GitHub Repository
You can find code of this newsletter issue at this GitHub Repository
"Success is never owned, its rented and rent is due every single day" — Rory Vaden
Let’s Connect on Social Media
Connect with me on LinkedIn (2.6K+ Followers) and Twitter.