What will you learn in this lecture?

In the previous video, we took the synchronization quiz. In this video, we will learn the answers to the quiz.

Synchronization Quiz Answer

Cool.

So how did you do?

Hopefully, that wasn’t so bad. I’m guessing you spent at least 20 minutes trying to figure this out.

If you spent more, of course, not a problem. This wasn’t an easy exercise. 

But it was a medium style exercise but of course, you’re learning new skills so it may have taken you a little extra time.

And if you went through it and actually got it working, that’s fantastic!

That’s one of the most important skills to have is to be able to persevere through failures because they’re very common with Selenium webdriver especially as we’re learning and writing test automation.

So here’s my solution. Keep in mind that your implementation may have differed from mine.

As long as your logical reasoning made sense and was similar to mine you should be okay

The locators all that kind of stuff there’s you know obviously many different directions that we could have gone.

I’ll tell you why I made the decisions that you made and if you think that your decisions were better and that’s cool your implementation could be better but if not you can kind of use my logic to help guide you.

In the future so standard opening up ultimateqa.com, not a problem of course we had to maximize the window because if you didn’t and you have a small size window, my browser, my website is responsive so all the links disappear and so you get this kind of style of navigation so anything after that would make everything really hard.

So you got to make sure that you maximize your browser then after that I set a webdriver wait and then I already told you which element to sync on and that was that image that I forget what it was called but it was that image that was one of the last elements to load.

So all I did was use its class name that was a unique class on that page and I synchronized to make sure that the element is visible waiting for a maximum of 5 seconds.

So once that element is visible we can perform the next action. For the next action, I chose to do another expected and other explicit waits.

The reason I chose to do that was because I know that after that element loaded, thre are several other elements that were loading.

Let’s show that again.

The waterfall chart in the network. Let me refresh my page. So as you can see, there’s a lot of stuff going on here.

There’s stuff going on here and stuff going on here as well that’s taking extra time and the element that we found it was a JPEG, I believe . Give it a second.

Oh no. I’m way up here, yeah, JPEG. so here see banner.

It’s kind of like toward there’s many more elements after it that load you can see here so I wanted to keep it safe and just use another implicit explicit wait. And so I use an explicit wait using by link text for the automation exercises which are right there. So I was looking for an element found with link text so you know worst case, if it’s already there we just proceed. If not, it will wait for an extra five seconds which is better than a flaky failure.

Next, we went to the automation exercises page.

Here I looked at the waterfall chart and then I was able to see that actually it’s funny because now the waterfall chart looks different. Then I saw it before but I chose to synchronize on the header text because actually when I analyzed it the waterfall chart was pretty similar. 

We’re actually all of the elements were loading almost simultaneously.

I wonder if it’s because I had it cached. I’m not sure but when I looked at it almost all the elements were loading at the exact same time so, I just chose an obvious one which was to use the header that contains the text automation practice and then once the header was loaded and now seeing the waterfall chart again it may have been a mistake.

I might have wanted to synchronize on something else and I’m actually looking for something else here. Maybe this Amazon PNG or Oh or maybe yeah maybe that Amazon PNG could have been good this one right here.

Let’s see. Yeah maybe this Amazon PNG could have been one of the better elements so that was possibly it could be improved on mind but after I synchronized on that I clicked the link with link text called big page with many elements and then after that I did a final synchronization which was checking for this image called girl with laptop.

So that was happening somewhere towards the bottom here let’s keep looking um trying to see it and give me as oh it’s down here all the way at the bottom you can see girl with laptop JPEG.

So there’s girl looking at a laptop. So that was an element that I chose to synchronize on. 

Why? Because it’s one of the last elements to load in our waterfall chart on our website so using the title I was obviously able to nope sorry about that I was able to go into elements and then using control laughs I was able to search for a girl – with laptop so here I have that element.

You can see that this element actually has a title which is great and then I used the title which is girl with laptop – and so that was the title that I searched for and then I just had an assertion that that element was displayed and so that was the test with proper synchronization.

If I run it for you which is always the funniest part.

No. I shouldn’t have debug this but I should run it. But it doesn’t matter if I run it for you. 

You’ll see that the test runs successfully. All the synchronization points have been placed well and I believe that whatever environment this test runs in it will not fail because all the synchronization points are in the appropriate conditions.

So we can just take a look here.

It’s gonna expand the browser as you see is gonna click the automation exercises it’s waiting for it to load as you saw now it’s waiting for this page to load as well and then it’s closed because everything on the page is loaded and we get a green checkmark saying that our test has passed.

So if you did it, congratulations. You’ve successfully mastered synchronization now just continue to apply these techniques to the rest of your automation tests.

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

Next Tutorial

This is the final video tutorial of the course about Selenium Webdriver implicit and explicit 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.”]

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