In This Course

In this course, you will:

1. Learn the problems that can occur as a result of improper synchronization

2. Learn how to use Selenium Webdriver explicit waits

3. Master Selenium Webdriver implicit wait

4. Understand what a DefaultWait is

5. Comprehend how to use all of the different types of waits during appropriate situations

Free Video Course

In this Lecture

This discussion talks about the last lecture on Explicit Waits quiz. This enlightens you on which of the methods are slowest. It also clearly explains why one of them is slower than the rest.

Selenium Tutorial – Explicit Waits Quiz Answer

What I did was I ran all of the tests. In here, I traced that right line, I inserted the name of each of the methods so that it’s pretty clear how long it took for each element to be identified.  Let’s see how you did.

Which one of these methods would have been the slowest?

If you look at the Test Explorer, we can see that we have four passed tests. If we move over each one, we can see the elapsed time. This is the elapsed time over the test not actually element identification. If we look here 10, 17, 11 and 10 seconds.

We look at this 17-second one, we go inside out of the output. We can see that the time elapsed for element identification was ten seconds. If we go back to our WebDriverWait class, ExplicitWait1. This is the one that uses the Thread.Sleep of ten thousand milliseconds. Therefore, it is the slowest, which makes sense because all of our other ones.

Check out this output 5.3 seconds. Check out this output 5.2 seconds and the first one 5.3 seconds. They are almost pretty similar because they are explicit waits that dynamically pole.

However, this one is a hard coded explicit wait that will sleep for ten thousand milliseconds no matter what. Even though the page is loading faster, it still has to wait for those ten thousands seconds. Therefore, no matter what happens, no matter how fast the application is, this test will always run in a minimum of 17 seconds.

It maybe plus or minus a few seconds depending if it’s faster but it will minimally wait for ten thousand milliseconds and then all the other actions will occur after that.

For the other tests, they will obviously happen faster because as soon as the element is located the test will proceed forward. That’s why this guy is the slowest. That’s why I strongly recommend that you use explicit waits with ExpectedConditions like in these cases.

If you find the need, to use this constructor, go ahead and use it but for most of you probably this constructor will do just fine and you’ll be able to locate your elements using these kinds of statements.

Pin It on Pinterest

Shares
Share This