Recently, one of my followers asked me to look into his test automation script. He was not able to click on the particular element on the web page and he could not figure out why. I have quickly found a root cause and we both found a workaround. But what caught my attention is that {force: true} flag was used almost everywhere in the action commands such as click(), check(), and so on. The test was also very flaky because of that. Let me share more about it.
The power of {force:true}
Test flakiness
Disabling the actionability check by using {force: true} you may fix the problem - your script is working, and the framework can perform the click on the desired button. Quick and easy solution. At the same time, you remove the "stability fuse" from your script! Framework is not helping you anymore, it's just doing what you are told to do.
Removing the actionability checks inavitably results into more flaky tests. The more force you use - the more flaky tests you get. And it can grow into a complete mess where will be hard to understand the root cause of the stability issues.
What is the solution?
Need to find a way to write the test script without using force.
A few things that you can start with are the following:
Removing the actionability checks inavitably results into more flaky tests. The more force you use - the more flaky tests you get. And it can grow into a complete mess where will be hard to understand the root cause of the stability issues.
What is the solution?
Need to find a way to write the test script without using force.
A few things that you can start with are the following:
- Analyze the test script and the log output. It often may give you a clue about what is happening
- Understand your application. Talk to developers and ask questions about observed behavior. They can provide the suggestions or make a fix (it can be a bug)
- Look for workaround, to avoid using force as best as you can