InterviewSolution
| 1. |
What is Fluent Wait and how to use it in WebDriver? |
|
Answer» WebDriver has various wait commands that help to overcome issues due to variation in a time lag. Web driver checks whether an element is present or visible or enabled or clickable etc. The Fluent wait is one of the Explicit waits. In Fluent wait, you can DEFINE the maximum AMOUNT of time for a condition and frequency with which to CHECK the condition before throwing an exception. In short, fluent wait tries to FIND the web element repeatedly at regular intervals of time until the timeout or till the object GETS found. Mainly FluentWait command is used when web elements are visible in few seconds and sometimes take more time than usual. Two main components of fluent wait are - Timeout value and polling frequency FluentWait syntax is - Wait<WebDriver> wait = new FluentWait(WebDriver reference) .withTimeout(timeout, SECONDS) .pollingEvery(timeout, SECONDS) .ignoring(Exception.class); Wait<WebDriver> wait = new FluentWait(driver).withTimeout(30, SECONDS).pollingEvery(5, SECONDS).ignoring(NoSuchElementException.class); |
|