What will you learn in this lecture?

In the previous video, we have learned the 2nd example of an implicit wait. In this video, we will learn how to make implicit wait work.

How to Make Implicit Wait Work

So the question you probably have is when will implicit wait actually work?

Well, let’s cover that example. Here’s another test that I wrote, test 2. The reason that I am calling this test 2 is because we are going to a different URL.

So now, using the same URL as before which is ultimateqa.com. You know the best website in the world. I’m joking of course, but it’s gonna go to ultimateqa.com. We are going to set an implicit wait of 5 seconds. And then, it’s gonna try to look for an element with ID success.

So let me actually show you ultimateqa.com here. And as you can see, here’s ultimateqa.com.

I pulled up the URL, I’m sorry, the webpage and I searched for the string success. And it’s nowhere to be found. Okay, it’s nowhere in the HTML. Nothing that the success which means there’s no ID success.

Okay, so now with that said, let’s go ahead and run this test and pay attention to how long this test to execute.

So we gonna start running this test. Just remember how fast the test above failed whenever an element wasn’t found.

Check this one out, so it’s pull up the webpage. And now the test is not finishing.

What did it do?

It actually was waiting for 5 seconds to find that element. So if we actually come here and look up this fail, you can see this a 13-second runtime for this entire test.

So that’s because it was waiting for the 5 seconds before getting to the step.

You don’t believe me.

I can throw breakpoint here. I can debug this. Let me pull it up over here and I’m gonna

step over this.

And watch how long it takes to get from this step to this step.

Step over.

Oh, I’m sorry, from this step to this step because this step has the implicit wait.

It doesn’t do anything. This is the one that actually does something. So watch on takes from here to this curly brace.

See how it starts and doing anything and boom. An exception is thrown, no such element exception.

No element, no such element.

Unable to locate element which is exactly what happens when an element was not found.

Does that make sense to you?

Because the element si not in the HTML, that’s when the implicit wait works. And so that is when it’s actually useful.

However, remember that if you set an implicit wait (in the future I will teach you other waits), you cannot mix them. I’ll you that in the future. Don’t worry.

But you cannot mix implicit wait and other waits which is one of them is explicit waits.

It’s not recommended by the Selenium community.

So, that’s what it means.

You shouldn’t use an implicit wait at all. Ever.

[Tweet “Learn everything you need to know about Selenium Webdriver implicit and explicit waits.”]

Next Tutorial

In the next tutorial, we will have a quiz on implicit waits.

What will you learn in this course?

Are your automated functional tests flaky? Do they randomly fail and you are unsure why? Is your team frustrated with the “instability” of your Selenium Webdriver tests?

If you are interested in fixing all of these problems and making your tests more stable, then you need to understand how to use all of the different types of waits in Selenium Webdriver. Knowing how to handle synchronization issues will make you a top-notch Test Engineer!

“The best tutorials I have ever seen, simply awesome. I take off my hat in front of you, you are a gorgeous professor, I am speechless to express how satisfied I am with these tutorials.” -Lisbey

In this course from Ultimate QA, you will learn:

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

– Learn how to use Selenium Webdriver explicit waits.

– Master Selenium Webdriver implicit waits

– Understand what a DefaultWait is

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

Take This Entire Course for Free

[Tweet “Learn how to correctly use implicit and explicit waits using #Selenium #Webdriver.”]