whats is alternate solution of fluent wait wait.until() method in selenium 3.x.x ?
It is giving some functional reference for util method.
Please guide.
whats is alternate solution of fluent wait wait.until() method in selenium 3.x.x ?
It is giving some functional reference for util method.
Please guide.
Advance Webdriver Waits create our own Custom Waits or Advance WebDriver Waits.please refer to this link.
http://toolsqa.com/selenium-webdriver/advance-webdriver-waits/
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://toolsqa.wpengine.com/automation-practice-switch-windows/");
FluentWait<WebDriver> wait = new FluentWait<WebDriver>(driver);
wait.pollingEvery(250, TimeUnit.MILLISECONDS);
wait.withTimeout(2, TimeUnit.SECONDS);
Function<WebDriver, Boolean> function = new Function<WebDriver, Boolean>()
{
public Boolean apply(WebDriver arg0) {
WebElement element = arg0.findElement(By.id("colorVar"));
String color = element.getAttribute("color");
System.out.println("The color if the button is " + color);
if(color.equals("red"))
{
return true;
}
return false;
}
};
wait.until(function);
}
You can integrate fluent wait with the explicit wait like below
/*
* wait until expected element is visible
*/
public boolean waitForElement(WebDriver driver, By expectedElement) {
boolean isFound = true;
try {
WebDriverWait wait = new WebDriverWait(driver, timeoutInSeconds , 300);
wait.pollingEvery(2, TimeUnit.SECONDS);
wait.until(ExpectedConditions.visibilityOfElementLocated(expectedElement));
makeWait(1);
} catch (Exception e) {
//System.out.println(e.getMessage());
isFound = false;
}
return isFound;
}