I am trying to automate a test case where i submit the form by clicking on an image.
After the page reloads i am not able to interact with any element on the webpage
I am using java , firefox driver.
The code gets stuck and is not able to identify the element at all.
Is there any wait mechanism with webdriver like there is with QTP , selenium ?
2 years later, ruby implementation:
wait = Selenium::WebDriver::Wait.new(:timeout => 10)
wait.util {
@driver.execute_script("return document.readyState;") == "complete"
}
Just use FluentWait class:
/**
* An implementation of the {@link Wait} interface that may have its timeout
* and polling interval configured on the fly.
*
* <p>Each FluentWait instance defines the maximum amount of time to wait for
* a condition, as well as the frequency with which to check the condition.
* Furthermore, the user may configure the wait to ignore specific types of
* exceptions whilst waiting, such as
* {@link org.openqa.selenium.NoSuchElementException NoSuchElementExceptions}
* when searching for an element on the page.
*
* <p>Sample usage:
* <code><pre>
* // Waiting 30 seconds for an element to be present on the page, checking
* // for its presence once every 5 seconds.
* Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
* .withTimeout(30, SECONDS)
* .pollingEvery(5, SECONDS)
* .ignoring(NoSuchElementException.class);
*
* WebElement foo = wait.until(new Function<WebDriver, WebElement>() {
* public WebElement apply(WebDriver driver) {
* return driver.findElement(By.id("foo"));
* }
* });
*
or WebDriverWait.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With