使用Selenium获取活动AJAX请求的计数


Get count of active AJAX requests with Selenium

我在Selenium上测试我的Yii应用程序。对于等待执行AJAX请求,我使用:

$this->waitForCondition('selenium.browserbot.getCurrentWindow().jQuery.active == 0');

它很管用。如何获取活动AJAX请求的计数?此代码:

$count = '+';
$this->storeEval('selenium.browserbot.getCurrentWindow().jQuery.active;', $count);
echo $count;

显示+

要检查我尝试过的活动请求,请使用:

if ($this->verifyEval('selenium.browserbot.getCurrentWindow().jQuery.active', 0)) echo 'active requests more than 0';

但它返回了错误:

Failed command: verifyEval('selenium.browserbot.getCurrentWindow().jQuery.active', '0')
Failed asserting that '1' matches PCRE pattern "/^0$/".

感谢的帮助

我自己找到了解决方案

$this->getEval('selenium.browserbot.getCurrentWindow().jQuery.active')