Validate network requests using Selenium and Python
In Back-End testing of web application it is very important to capture the network request and validate whether they are properly performing or not. For an example , you are submitting a form in a web application. In UI it is showing that submission is successful. But when you check in the database, you observe that values have not been updated. Back-end requests of applications are sometimes responsible for this kind of error.
In automation testing we can automate this kind of validations. Python has an extend package of its selenium bindings which is capable to access the underlying requests made by the browser. This package is selenium-wire. Along with the capabilities of selenium this package has an additional API for accessing things such as the request/response headers, status code and body content.
Installation: This package requires minimum python 3.4 and supports all the latest versions. And also Selenium 3.4.0+ . Currently Chrome, Firefox, Safari and Edge are the browsers which supports selenium-wire. To install the package use the following command in terminal -
$ pip install selenium-wire
Following is a sample code on how to use this packge
from seleniumwire import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from…