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 wait
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 lectures answer the question the the DefaultWait Class Quiz. This gives you a better understanding when implementing DefaultWait when using the WebDriverWait Class. This also talks about which one between the WebDriverWait class or DefaultWait class is easy to use.
Selenium Tutorial – DefaultWait Class and Quiz Answer
Let’s see how you did. Our requirements were that we want to implement this DefaultWait using the WebDriverWait class. We want to have a timeout of 10 seconds and we want to be able to poll every second. Using our WebDriverWait class, remember the WebDriverWait class is two constructors.
This one allows us to set two properties but it doesn’t allow to poll but this one does allow to poll so this is the one we want. Then the PollingInterval is one and then clock, we need to implement that so I’m going to do create a local variable and then I need to initialize it. Awesome!
If you take a look at this statement we have our WebDriverWait class, has a clock, has a driver and then the two important components which is the maximum timeout. The timeout is 10 seconds here, just like it is there and then our PollingInterval in our DefaultWait was 1 second and then we created our PollingInterval of 1 second here. Basically, it’s exactly the same thing as this statement above.
Therefore, that is why it’s not so commonly used by QA engineers because again if we look at the WebDriverWait class, you guys can see that it has these two nice implementations that basically rubbed the DefaultWait and make it much easier for us to use.
Yes, we don’t get the functionality of ignoring reception types and the messaging but it’s that really important for you, I don’t know, that’s up to you to decide. I personally don’t use it so often. In fact, I almost have never used the DefaultWait class. I just wanted to make you aware that it does exist and that it’s therefore your usage if you desire to use it.
Like I said, it’s probably not worth your time to be investing a lot of resources and to setting up this convoluted WebDriverWaits and maybe defining your own expected conditions if you want to do that. There are much more valuable resources in Selenium WebDriver that you should learn as opposed to learning the DefaultWaits. Again, it’s here for you if you need it. You know how to use it now and the knowledge hopefully should be in your head.