Hire QA – Specialized in QA Recruitment, Technical Interviews and Testing Solutions

Fluent Wait in Selenium

Category: Selenium WebDriver

The Fluent Wait in Selenium is used to define maximum time for the web driver to wait for a condition, as well as the frequency with which we want to check the condition before throwing an “ElementNotVisibleException” exception. It checks for the web element at regular intervals until the object is found or timeout happens.

Frequency: Setting up a repeat cycle with the time frame to verify/check the condition at the regular interval of time.


FluentWait wait = new FluentWait(driver);
.withTimeout(30, TimeUnit.SECONDS)
.pollingEvery(5, TimeUnit.SECONDS)
.ignoring(NoSuchElementException.class);
WebElement element = wait.until(new Function<WebDriver, WebElement) {    
    public WebElement apply(WebDriver driver) {    
        return driver.findElement(By.id("element"));    
    }
});

Leave a Reply

Your email address will not be published. Required fields are marked *