Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Selenium WebDriver Waits

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 369
    Comment on it

    Different types of Selenium WebDriver Waits:

     

    Waits helps the user to solve the issues which comes while redirecting to different web pages, by refreshing the web page and reloading the new web elements. At times there can be Ajax calls as well. So, a time delay occurs while reloading the web pages and reflecting the web elements.

     

    WebDriver provides two types of waits to handle the loading of reappearing page & web element, windows appearance, pop ups and error messages and display of web elements on the web page:

     

    • Implicit Wait
    • Explicit Wait

     

     

    1. WebDriver Implicit Wait:

     

    Implicit waits are utilize to provide a default waiting time into each following test step/command over the complete test script. So, the next test step will be performed when the 30 seconds have passed after the previous test step.

     

    Key Notes:

     

    • It is a single line code. It can be declared in the setup method of the test script.
    • Its syntax and approach is simpler.

     

    It is easy and simple to apply but it has some drawbacks as well. It increases the test script execution time as each command will stop to wait for a specified time before restart the execution.

     

    Import Statements:

     

    import java.util.concurrent.TimeUnit – We have to import this package before applying the implicit wait.

     

    Syntax:

     

    drv.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

     

     

    2. WebDriver Explicit Wait:

     

    It is used to stop the execution until the time for a particular condition is met or the maximum time has passed. Also, it is only applied for a particular case.

     

    WebDriver has two classes to apply the Explicit waits into the test scripts:

     

    • WebDriverWait
    • ExpectedConditions

     

    Import Statements:

     

    We have to import this package before applying the explicit wait:

     

    import org.openqa.selenium.support.ui.ExpectedConditions

     

    import org.openqa.selenium.support.ui.WebDriverWait

     

     

     

     

     

     

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: