开发者

Can Selenium monitor XHR requests

开发者 https://www.devze.com 2023-02-13 07:35 出处:网络
Is there any way in Selenium to mo开发者_C百科nitor the XHR requests from an application. I want to create a test where the test clicks a button then checks to see if a correct Ajax request is made.

Is there any way in Selenium to mo开发者_C百科nitor the XHR requests from an application. I want to create a test where the test clicks a button then checks to see if a correct Ajax request is made.

Edit, I am using PHP Unit if that matters.


You can capture the network traffic with Selenium and then try get what you need for that

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

And then do your asserts by finding what you want in the traffic.

0

精彩评论

暂无评论...
验证码 换一张
取 消