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
In This Lecture
This lecture specifies the main problems that you’re going to face when doing a GUI Testing. You’ll know the importance of synchronization and GUI Testing. You will also learn about TryFind Method.
Selenium Tutorial – Why is Synchronization Important?
When doing automated functional GUI testing, you’re going to run into two main problems.
First is element identification and second is synchronization. What it is about synchronization that makes it so hard and so important for automated functional GUI tests? Why are we going to cover this topic? Why synchronization?
Before we get into that, I want to take you guys through a little exercise. I’m going to bring out my visual studio here and grab this quick little link. Then, I’m going to go to this website.
Here, you guys can see that there is this very simple page that you can click the Start button on. Then, it’s going to load for a little bit and then a web element is going to show up called Hello World!
The test that I want to design is going to do exactly that. It’s going to hit the Star button and then it’s going to make sure that “Hello World!” shows up.
I wrote a simple test here that I’m going to explain to you guys. Up here, I have a test initialized method where I do a set up. I am using this class that I created for initializing my web drivers. I’ll explain to you guys why I put these methods into this class later. For now, if we take a look at basic initialize, which is over here. Basic initialize all it does is it creates a new 55-driver instance.
That’s what the setup does. Then, we have a tear down method, which obviously runs at the end of the test and all it does is close the driver and then quit, closes the browse and then quit. It closes every associated window.
Then the meat of the actual test is my dynamically loading elements test failure method. Here, I have a method called the TryFind. The reason that I put in a TryFind method, I’ll tell you guys a little bit later as we proceed.
It’s very simple. Inside the TryFind method we just navigate to our URL that I specified above, I just showed you guys which URL that is. Then we click on the button using its tag name button. Then, we get the text that is found using one of my favorite XPath expressions. It’s the text that contains Hello World! Finally, we try to click on that text.
That is what the TryFind method does. At the end of the day, what this is going to do is exactly what I showed you manually. Let’s go ahead and step through this.