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 waits

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 video is made to give the Selenium WebDriver Answer on the quiz, why does your test fail when it runs. This emphasizes the importance of synchronization when running tests. You want your test to be running on the same speed as the actual application test.

Selenium Tutorial – Answer: Why Does Your Test Fail When It Runs

Let’s see how you guys did and why did this test actually fail. If you pay close attention to the page here on the right, what I’m going to do is I’m going to hit the start button and you guys see this loading. After the loading screen comes up the, “Hello World!”

If you take a look at the code, we navigate to the URL, we hit the start button and then we check to see if “Hello World!” is present. That is where actual problem is. That little quiz was a prelude to the idea of synchronization, which I wanted you guys to think about before we dive into it.

The idea of synchronization is you want your test running on the same speed as the actual application on the test. You don’t want it running too fast and you don’t want it running too slow. This is because both of those situations lead to negative outcomes from your test.

On our case, the test was moving too fast for the application. We were navigating to our URL, we were clicking the start button. Then we were looking for an element that was not there because the loading bar was still loading. We are trying to find the element that didn’t find the element. It said, “No element there, sorry. Let me throw an exception.” That is exactly what happened.

Let me show you guys from the actual HTML. If you look over here, at the HTML and we look in here and we can see that there is a “Hello World!” present in the HTML but it’s style is display none so it’s not being displayed.

Obviously, until this loading bar at that point, if we hover over then click it, “Hello World!” does not have the style of display non anymore, instead the start and loading icons are now display none because they are no longer displayed on the page. They are hidden and they can’t be interacted with but “Hello World!” can and now be interacted with.

That is the whole reason why our test failed because when I was stepping through it, I was slow enough for the application to catch up to our test. When I ran it in the actual continuous integration environment, by continuous integration, I mean running it on my computer the test failed because it was too fast.

 

Pin It on Pinterest

Shares
Share This