Can Selenium track XHR requests

Is there a way in Selenium to track XHR requests from an application. I want to create a test in which the test presses a button, then checks if the correct Ajax request has been made.

Edit, I use the PHP module, if that matters.

+4
source share
1 answer

You can capture network traffic with Selenium and then try to get what you need for this

Selenium s = new DefaultSelenium(...); s.start("captureNetworkTraffic=true"); s.open("http://www.google.com"); String traffic = s.captureNetworkTraffic("json"); 

And then make your statements by finding what you want in traffic.

+5
source

Source: https://habr.com/ru/post/1341117/


All Articles