-3

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.

  • https://stackoverflow.com/questions/47575339/handle-the-nosuchelementexception-in-fluent-wait/47575486#47575486 – Mahmud Riad Dec 01 '17 at 06:10
  • Your question isn't clear. Why do you need an alternate to WebDriverWait or FluentWait? They both exist in Selenium 3. – JeffC Dec 01 '17 at 20:59
  • Because wait.until no more works in selenium 3. So i am seeking alternative way to handle until method. – Kalpesh Patel Dec 02 '17 at 04:41

2 Answers2

2

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);
}
-1

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;
}
Mahmud Riad
  • 1,169
  • 1
  • 8
  • 19