Selenium可以监视XHR请求吗 [英] Can Selenium monitor XHR requests

查看:163
本文介绍了Selenium可以监视XHR请求吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Selenium中是否可以监视来自应用程序的XHR请求.我想创建一个测试,其中该测试单击一个按钮,然后检查是否发出了正确的Ajax请求.

Is there any way in Selenium to monitor 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.

编辑,如果重要的话,我正在使用PHP Unit.

Edit, I am using PHP Unit if that matters.

推荐答案

您可以使用Selenium捕获网络流量,然后尝试获取所需的内容

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.

这篇关于Selenium可以监视XHR请求吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆