How do you make Selenium 2.0 wait for the page to load?
How to get Selenium to wait for page load after a click provides the following interesting approach:
WebElement
from the old page.WebElement
until StaleElementReferenceException
is thrown.Sample code:
WebElement link = ...;
link.click();
new WebDriverWait(webDriver, timeout).until((org.openqa.selenium.WebDriver input) ->
{
try
{
link.isDisplayed();
return false;
}
catch (StaleElementReferenceException unused)
{
return true;
}
});