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 talks about the answer on the Implicit Waits Quiz. Here, you’ll learn about keeping your code safe, where you can find and download it if you need it for reference. This discussion also talks about DRY, Don’t Repeat Yourself.
Selenium Tutorial -Implicit Waits Quiz Answer
Let’s see how you did. The way I could have done and of course, you can always do everything in many ways. The way I did it was to keep this code safe for you, which is obviously available on GitHub for you to download, if you need it for reference.
I just created a new test. I named it the same but I called it FixedImplicitly so that you guys know what I would have done. Inside of the test, I set the implicit wait and then I called the TryFind Method. Remember in the beginning I told you why I created that TryFind Method, that’s because I want to keep reusing this code.
Just following the standard DRY principle of “Don’t Repeat Yourself,” I didn’t want code forward this code in there and then copy and paste it in here as well. Why do I do that two times? Instead, I can have a test method that tries this code and fails and then I can have a method that works and it was fixed with an implicit wait and I put that right here. I think five seconds is enough to see that element load.
I hope you did something similar. You obviously could have taken this and put it inside of the TryFind Method as well or maybe somewhere before the driver navigates or you could even actually put it up here in the class and set it there but this is the way I chose to do it just so that it’s easier for demonstration purposes. All the codes exist for you whenever you are ready to look at it.
Let us actually go ahead and run this test to see what happens. I’m going to go in here and click run tests, move this to the left, give it a second to pull up FireFoxDriver. It pulled up on my other screen. There it is, it is loading, “Hello, World!” loaded and boom.
We got a green check mark right here our test has now passed. If you want to make sure, you can always re-run this method to see that it actually fails. We fixed it with an implicit wait of waiting for five seconds.
If you did that fantastic! Great job, you understand implicit waits.
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