I am using something like following to wait for ajax request to
complete in javascript. This works in IE and firefox but this is not
working in Chrome. After Webdriver threw exception, I opened
Developers Tools Console in chrome and manually typed 'jQuery.active'
it returned 0 and works fine. I am wondering why ChromeDriver is
throwing exception if it works manually. I also copied the log from
the chrome console of the failure of jQuery.active by webdriver.
public void waitForAllAjaxRequests(){
while (!((JavascriptExecutor)driver).executeScript("return
jQuery.active;").toString().equals("0")) {
waitForAllAjaxRequests();
}
Is there anything I am missing or any alternative?
Thanks,
-Nilesh
Environment
-------------------------------
Selenium 2.0b2/Java; Windows XP; Chrome 10.0.648.127
Chrome Developers Tools- Console Output
-------------------------------
executing (function anonymous() { return jQuery.active;}).apply(null,
[]) with timeout -1
evaluate.js:115returning from injected script: {"statusCode":
17,"value":{"message":"ReferenceError: jQuery is not defined"}}
chrome-extension://mkacpknkoaochenndpbhpaldjkiecahh/content_script.js:
870Got response: {"statusCode":17,"value":{"message":"ReferenceError:
jQuery is not defined"}}
jQuery.active ----> This was executed by me manually
0
Webdriver Exception
-------------------------------
org.openqa.selenium.WebDriverException: ReferenceError: jQuery is not
defined (WARNING: The server did not provide any stacktrace
information)
System info:
os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1',
java.version: '1.6.0_19'
Driver info: driver.version: RemoteWebDriver
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown
Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown
Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at
org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:
131)
at
org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:
105)
at
org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:
410)
at org.openqa.selenium.chrome.ChromeDriver.execute(ChromeDriver.java:
85)
at
org.openqa.selenium.remote.RemoteWebDriver.executeScript(RemoteWebDriver.java:
319)