Time for action – using explicit waits with Selenium WebDriver - Selenium

In this section we will have a look at using explicit waits.This is useful for making sure that the right type of exception is thrown:

  1. Open your Java IDE.

  2. We are going to use the following code. WebDriverWait is found in the Support package within the Selenium WebDriver Jar.

  3. Run your tests:

    What just happened?

    We have just seen how we can use an explicit wait with our code. We told the wait class that we wanted it to wait ten seconds while trying to find the element. I personally prefer explicit waits since you can see by reading the code how long it is going to wait for.
    Let's now see what we have learnt in this chapter.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Selenium Topics