Reputation: 21
I'm having some issues on my page load, as the page loads some asynchronous stuff, I would like to interrupt the page load to proceed with the next steps of my test.
1- The driver.get(url) this throws timeoutException after 1800 sec loading.
2- I have added driver.manage().timeouts().implicitlyWait(TEST_WAIT, TimeUnit.SECONDS); it didn't change anything.
I did driver.manage().timeouts().setScriptTimeout(time, unit) no change too
3- The last try was the following JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("return window.stop()"); this didn't work
How can I solve this?
Upvotes: 0
Views: 1481
Reputation: 921
Solution : Below solution might resolve your problem of wait. Lets try !
static void waitForPageLoad(WebDriver wdriver) {
WebDriverWait wait = new WebDriverWait(wdriver, 60);
Predicate<WebDriver> pageLoaded = new Predicate<WebDriver>() {
@Override
public boolean apply(WebDriver input) {
return ((JavascriptExecutor) input).executeScript("return document.readyState").equals("complete");
}
};
wait.until(pageLoaded);
}
Upvotes: 0
Reputation: 27486
Have you tried setting the page load timeout?
driver.manage().timeouts().setPageLoadTimeout(time, unit);
This should throw the TimeoutException
when the timeout expires, which you can catch and move on to the next operation. Caveats (may not be implemented in all browsers, behavior might differ) apply.
Upvotes: 1