FREE MEANS 100% FREE IT’S TOTALLY FREE

Wait in Selenium

WebDriver enables the user to choose among the available wait to handle situations  where the execution flow may require a sleep for few seconds in order to load the web elements or meet the specific condition.

There are three types of wait are available in WebDriver

  1. Implicit waits  are used to provide a default waiting time between each consecutive test step/command access the entire test script. Or once it is declared it will be available for the enter life of the WebDriver instance. In real world situation, every  test steps/conditions do not need to wait, therefore implicit wait causes slow the process.
  2. Explicit Waits are used to halt the execution until the time a particular condition is meet or the maximum time has elapsed. Unlike implicit wait, explicit waits are applied for a particular instance only. (Explicit Wait + ExpectedCondition)
  3. Fluent wait, let’s say you have an element which sometime appears in 1 second and sometime it takes minutes to appear. In that case it is better to find element again and again until it find it or until the final timer runs out.
  4. Page Load Time Out
  5. Set Script Time Out

Some basic questions and answer from Test Automation School

  • What does this WebDriver command do? manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS)
    • Wait up to 5 seconds any time an element that it need to interact with is not really present.
  • Which Selenium class allows you to do explicit waits?
    • WebDriverWait
  • Explicit waits will always wait the entire time specified by the timeout.
    • False
  • Which type of wait strategy allows you to specify the condition to wait for?
    • Explicit Wait
  • Which Selenium class is used to note the type of condition to wait for?
    • ExpectedConditions
  • To wait for an element to disappear, which method should be used?
    • invisibilityOf()
  • What happens if the element is still not found after waiting the specified amount of time?
    • An Exception has been thrown
  • Fluent waits allow you to ignore exceptions that may be thrown when polling for an element?
    • True
  • Selenium provides a method to allow you to wait for the page to completely load.
    • True
  • The purpose of the setScriptTimeout() method is to set the maximum amount of time it should take for the ________.
    • asynchronous JavaScript code to execute
Leave a Reply

Shopping cart

0

No products in the cart.