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 talks about why synchronization is important with automated functional testing. You’ll also learn more about the three problems resulting to improper synchronization. And then, you’d be able to understand the importance of proper synchronization when running tests.
Selenium Tutorial – Problems Arising Improper Synchronization
Why is synchronization is so important with automated functional software testing. The reason is because we writing code that actually test the code. Our code needs to literally mimic the functionality of the application. If it doesn’t do a good job of mimicking the functionality of the application this can lead to a lot of weird situations that occur with your code.
Problems with your synchronization throughout the test can lead to three problems:
- Intermittent failures
- False positives and negatives
- Slow test execution.
Did you guys see when we were debugging our code locally on our computer and we were stepping through it, everything worked. When we ran it in the CI environment, it did not work and it failed because the test was too fast for the application.
What it can do when your synchronization is not up to par is you can have these intermittent test failures. The developer takes the code and says, “By the way this works on VM. I don’t know why it’s failing in CI environment.”
You’ve seen a lot of bugs like that. You can have the same types of bugs with your automated functional testing code. We can be like, “I don’t understand why this test if failing when I stepped through it, on my VM. It completely works all the time. I’m completely clueless as to why it’s not working. “If it’s not working in the CI and it’s working on your VM, one of the reasons is your synchronization maybe off.
False Positives and Negatives
The other thing that improper synchronization does is it leads to false positives and negatives. Talking about intermittent test failures, you get false positives results saying that the test failed. The test is not really failing because the functionality is broken. The test is failing because your test is either too fast or too slow for the application.
The too slow part is where you have actually negative outcomes from your test cases. Because your test fails intermittently and sometimes, the results of when it fails are not correct. It may fail or it may not, depending on your synchronization. Sometimes the element loads faster, sometimes the element loads slower and that can lead to improper results.
You can’t trust your test whether it’s passing or failing, which is actually one of the worst things can happen when the entire team or even you lose the trust in your tests. When you stop trusting your tests that’s when things go really south. You need to able to trust your test and you need to make sure they are extremely solid and having proper synchronization is one way to do that.
Slow Test Execution
The final problem that can occur with that synchronization strategy is slow test execution. This mainly refers to when you use improper synchronization techniques. What’s going to happen is your test is going to run way too slow. Your application on their test is going to be running much faster than your actual code. You may not be acting like the end user on your functional, which you may be doing is waiting too long with every single step and wasting valuable time.
Effect of Improper Synchronization
Not only does this waste time, in the CI environment when all of your tests are running. And it’s taking multiple hours to run your test, when they could be run much faster. It’s also causing you time, when you debug these tests and they are running for way too long. All those minutes quickly add up leading to an inefficient process and maybe frustration. Not only from you but even from all your team mates and management because there’s a lot of time being wasted on automated functional testing. To handle these synchronization techniques appropriately, we need to learn a few strategies.