<<Previous Question <<1500 Plus Interview Questions>> Next Question>>
What are the different types of waits available in Selenium WebDriver?
Watch the answer for this Selenium Interview Question in a detailed manner in the below youtube video:
Note: Don’t forget to subscribe to my Youtube channel.
Notes used for explanation in this Youtube video are provided after the video:
Notes used in the above Youtube Video:
The following are the different types of waits available in WebDriver:
- > Implicit Wait
- > WebDriverWait
- > FluentWait
Waiting mechanism in Selenium and Java can be categorized as below:
More details on waits:
- > Thread.sleep()
- – Belongs to Java and will hard wait even after the element is displayed
- > Implicit Wait
- – driver.manage().timeouts().implicitlyWait() is a global wait and once declared at the beginning of the program or at the core of the framework level, will be applicable to all the web elements.
- > WebDriverWait
- – Waits explicitly for a specific web element
- WebDriverWait wait = new WebDriverWait(driver,5);
- WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText(“Facebook”)));
- element.click();
- – Waits explicitly for a specific web element
- > FluentWait
- – Also similar to WebDriverWait with more flexibility in polling time and ignoring exceptions
- //Waiting 30 seconds for an element to be present on the page, checking
- //for its presence once every 5 seconds.
- Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
- .withTimeout(30,SECONDS);
- .pollingEvery(5,SECONDS);
- .ignoring(NoSuchElementException.class);
- WebElement foo = wait.until(new Function<WebDriver, WebElement>(){
- public WebElement apply(WedDriver driver){
- return driver.findElement(By.id(“foo”));
- }
- public WebElement apply(WedDriver driver){
- });
Next Steps:
- > For more Selenium Interview Questions and answers, continue to the next post (Click on Next Post link below)
- > Check complete Selenium Interview Questions list here (Click here)
Please leave your questions/comments/feedback below.
Happy Learning ?
<<Previous Question <<1500 Plus Interview Questions>> Next Question>>
On a mission to contribute to the Software Testing Community in all possible ways.
very nice explanation
Thank you Prakash 🙂