HomeSelenium

Selenium Interview Question 10 – What are the different types of waits available in Selenium WebDriver?

Selenium Interview Question 10 – What are the different types of waits available in Selenium WebDriver?

<<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:

Different types of Waiting Mechanism in Selenium WebDriver

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();
  • > 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”));
      • }
    • });

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 🙂

About Me > Arun Motoori

<<Previous Question       <<1500 Plus Interview Questions>>       Next Question>>

On a mission to contribute to the Software Testing Community in all possible ways.

If you like this article, share it on LinkedIn using the below button:

Comments (0)

Leave a Reply

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