What will you learn in this lecture?

In the previous video, we have learned about implicit wait. In this video, we will learn the 2nd example of an implicit wait.

2nd Example of an Implicit Wait

So just to prove some of my points, what I’ve done here is I’ve created the same test and it’s called test one fixed implicitly. As you can see, it does exactly what it previously did. However, what it now does is it sets an implicit wait.

You can see here’s the usage that I’ve talked about. And I’ve said that the implicit wait to wait for five seconds. So we’re gonna fill out the credit card info and then we’re gonna find an element and then we’re gonna perform all the same actions as before. But what this means for Selenium webdriver now is any time it uses the find element method it’s going to wait for up to five seconds before it throws an element not visible exception and so it’s gonna wait for 5 seconds and then if it doesn’t work, it’s gonna throw up an exception.  Otherwise, it will continue to poll to see if that element is in the Dom before failing.

So let’s go ahead and step through this test.

Actually, let’s just go ahead and run it and see whether this test succeeds. So I’m gonna come here and just click run test and so now the test explorer is good, just gonna go ahead and build. It’s gonna build a couple tests and then it’s gonna start test execution.

We can look at the test explorer and we can see this green bar that keeps moving which means that the test is in execution mode. You can see the browser has opened up here. It’s gonna navigate to our URL, fill out the appropriate information and then it looks exactly like before the test failed again.

When we look at the error, we see the same exact error saying element not visible and then which is very weird.

Right.

Why is the element not visible? I just don’t understand.

Well, it’s exactly as I showed you. It’s the fact that implicit wait is totally useless when the element is hidden on a page. Let me show you. Look. I’m gonna go to this slow animations URL. I’m gonna copy it. I’m gonna open up a brand new browser here and then we’ll take a look at this element that I’m waiting for.

So, for we’re waiting this element called ID success okay and we’re supposed to wait for it for five seconds. So if I got Chrome up and then I look for that element I got Chrome tools up let me hide this over here and then remember we can use the command F feature. Control F if you’re on Windows and we can search by ID so I can actually just search.

Sorry, I forgot the ID that I was looking for success not go success. So if I search for the string success, you can see that there are three elements that I find and we can search through them. So here’s one there’s two and then there’s three okay so here’s the one that we want you can see that this is a div that contains an ID called success and although it is not visible on the page you can see that it’s in the HTML.

In fact, its display is none which means it’s hidden but it’s here in the HTML. But it’s not present on the page so what that means is it’s hidden which means that no matter what.

The implicit wait will never work and what that means is that you can’t resolve this problem using an implicit way that this situation right here you’ll never be able to solve it using an implicit waits.

Next Tutorial

In the next tutorial, you will learn how to make implicit waits work.

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

Nikolay Advolodkin is a self-driven SDET on a lifelong mission to create profound change in the IT world and ultimately leave a legacy for his loved ones, community, and the world at large. Today, he serves as the CEO and Test Automation Instructor at UltimateQA.com and contributes informative articles to leading test automaton websites like SimpleProgrammer.com and TechBeacon.com

Pin It on Pinterest

Shares
Share This