What are the types of waits present in the Explicit Wait in Selenium webdriver (Java)? Is there any types in Explicit Wait? if so please elaborate..
问题:
回答1:
There are following waits:
FluentWait
This is special wait where You can set time to wait for a certain condition, as well as the frequency with which to check the condition like eg. wait for 10s and check every 1s, and ignore "NoSuchElementExceptions" exception, if You anticipate that this exception will happen for some time
Wait wait = new FluentWait(driver)
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring(NoSuchElementException.class);
WebElement foo = wait.until(new Function() {
public WebElement apply(WebDriver driver) {
return driver.findElement(By.id("foo"));
}
});
Explicit wait It is kind of wait where You can set it up to wait for any condition you might like. Usually, you can use some of the prebuilt ExpectedConditions
Types of Expected Conditions: https://github.com/SeleniumHQ/selenium/blob/master/java/client/src/org/openqa/selenium/support/ui/ExpectedConditions.java
WebDriverWait wait = new WebDriverWait(driver, 10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(By.id("someid")));
Implicit wait wait for element, until exception is thrown while initialising object, and its defined through entire session
WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
driver.get("http://...");
WebElement myDynamicElement = driver.findElement(By.id("myDynamicElement"));
PageLoadTimeou How long it will until page is loaded:
driver.manage().timeouts().pageLoadTimeout(100, SECONDS);
SetScriptTimeout
if You have asynch scripts. Time to wait for an asynchronous script to finish execution before throwing an error.
driver.manage().timeouts().setScriptTimeout(100,SECONDS);
回答2:
There is no more types of wait in Explicit Wait as per my knowledge.We have only Implicit Wait, Explicit Wait and Fluent Wait.