What will you learn in this lecture?
In the previous video, we learned what’s next to implicit waits. In this video, we will learn about explicit waits.
What are Explicit Waits
So let’s talk a little bit about explicit waits. What is an explicit wait?
Well, an explicit wait is the code that actually you write to wait for a certain condition to occur before proceeding.
If you noticed with the implicit wait, we actually didn’t write any code to wait for any conditions. What we did was we set an implicit wait property to a specific time span. However, we didn’t write any code to be waiting for any kind of conditions.
We didn’t wait for an element to be hidden. We didn’t wait for an element to be visible or displayed or for text to be contained inside of an element or any kind of that stuff an implicit weight is already set by Selenium and it’s also set in the browser.
Each browser has their own implicit wait implementation and so we just said it. However, with an explicit wait, you write the code and tell Selenium webdriver to wait for a specific condition.
Don’t worry. You’ll see with code examples so usage. I will show you that in the code. It’s not gonna fit in this tiny little slide box. I’ll show you that in the code is that will be the best place to see all of this the default timeout for an explicit wait is half a second.
What does that mean?
It means that if you don’t specify the time for an explicit wait to wait for a specific condition, half a second will be the amount of time. There are waits before it throws an exception.
The disadvantages of an explicit wait are that, well, it’s actually only one is that you should be used for all slow loading elements which means that you might have a couple lines of code anytime you need to do a synchronization point.
So whenever you’re switching between different kinds of pages and you want to do have a synchronization point, you need a couple lines of code that utilize an explicit wait.
It’s not a big deal because that is kind of required for you to avoid flakiness. However it can, you know, obviously add a few lines of code to your code base.
So, when should you use explicit waits?
You should use them for all slow loading elements that need a synchronization point. So like I said, anytime you’re switching between pages and there’s a slow loading element synchronize on that element for that page prior to proceeding with any other actions, that’s when you use an explicit wait.
Now let’s go and actually look at the code.
See how explicit waits solve of all the problems their implicit waits fail to solve and then I’ll also show you the problems that Selenium, a new version of Selenium has caused us.
In the next tutorial, we will talk about the 2 types of 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