Skip to content

Instantly share code, notes, and snippets.

@dimacus
Created September 24, 2014 19:31
Show Gist options
  • Save dimacus/41075781108b4ef66f9c to your computer and use it in GitHub Desktop.
Save dimacus/41075781108b4ef66f9c to your computer and use it in GitHub Desktop.
def wait_for_ajax
Selenium::WebDriver::Wait.new(:timeout => 60).until do
sleep 1
@selenium.execute_script("return jQuery.active") == 0
end
end
public void waitForAjax() {
new WebDriverWait(selenium, 60000) {
}.until(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driverObject) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
Long
returnedValue =
(Long) ((JavascriptExecutor) driverObject).executeScript("return jQuery.active");
return returnedValue == 0;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment