Javascript 如何使用SeleniumWeb驱动程序PhantomJs跟踪或监视xmlhttp请求(Ajax调用)

Javascript 如何使用SeleniumWeb驱动程序PhantomJs跟踪或监视xmlhttp请求(Ajax调用),javascript,ajax,selenium,Javascript,Ajax,Selenium,我需要使用SeleniumWeb驱动程序PhantomJs查找当前文档中有多少ajax调用挂起,我没有对ajax调用对象的引用 我尝试执行以下javascript: var s_ajaxListener = new Object(); s_ajaxListener.tempSend = XMLHttpRequest.prototype.send; function increaseCounter () { window.ajaxRequestCount = window.ajaxReq

我需要使用SeleniumWeb驱动程序PhantomJs查找当前文档中有多少ajax调用挂起,我没有对ajax调用对象的引用

我尝试执行以下javascript:

var s_ajaxListener = new Object();
s_ajaxListener.tempSend = XMLHttpRequest.prototype.send;

function increaseCounter () {
    window.ajaxRequestCount = window.ajaxRequestCount + 1;
}
function decreaseCounter() {
    window.ajaxRequestCount = window.ajaxRequestCount - 1;
}
XMLHttpRequest.prototype.send = function() {
    increaseCounter()
    s_ajaxListener.tempSend.apply(this, arguments);
    this.addEventListener("progress", increaseCounter, false);
    this.addEventListener("load",decreaseCounter , false);
    this.addEventListener("error", decreaseCounter, false);
    this.addEventListener("abort", decreaseCounter, false); 
}
但是,在执行此操作时,browserInstance.execute_脚本(“return window.ajaxRequestCount”)输出为:
None