Success rate of "click" actions with Selenium? (Relatively)
I've used a tool called Ranorex for my test automation projects, and it has an annoying issue with click actions: They are not stable. A click on any element can be missed at any time, even when the element was loaded seconds ago and there's nothing on top of it.
As I'm getting more and more tired of seeing clicks being missed for no reason, I'd like to find another tool that can surpass this issue. And of course the first one I think of is Selenium, due to a noticeable difference: Ranorex uses real mouse pointer to simulate mouse actions, while Selenium doesn't.
I've worked with Selenium before, but I think I don't have enough experience to make an assessment of the success rate of "click" actions with Selenium. So I'd love to know about your opinions on this matter, like how good (in general) Selenium handles click actions in your opinion, how often you see Selenium misses a click, how often you have to find another way to click an element... Thank you very much.
First of all, we need to understand the root cause of the click failure.
There can be several reasons for that:
- Element is not loaded into the DOM at the moment of click action
- Element is not visible on the page at the moment of click action
And many more options. So in case, you are aware of these issues and correctly manage them (via your test framework), there should not be any problems. Waits are usually handled on the framework level via proxy methods and injecting them in the most brittle places.
As an inspirational example:
- See the implementation of Protractor framework and how it handles the AJAX/Angular testability
- Selenide framework and it's waits
- Many more examples of TAF that can be found on GitHub
Click method for web element itself is usually also customized/overridden with a combination of custom waits that would ensure that element is "clickable" (which is also a question to discuss, since there is no clear definition/standard for that condition) on the test automation framework level, so you can use the:
- Default Selenium IWebelement.Click() implementation
- Mouse click via Selenium Action builder API
From my experience - following these rules give you 99% stability and robustness of click events.