A technical solution is sometimes the worst
The most common problem found in a Selenium Java automation project is not finding elements.
In many cases, this can be fixed by using an explicit wait and expected conditions.
But sometimes, the problem persists because the HTML code of the page is just too bad.
And, when this happens, technical solutions are being proposed such as
reload the page; if the element is not in the page, maybe it will be there after reloading
retry finding the element; if the element cannot be found, maybe we can try a few more times
retry finding the element with Javascript
using self-healing mechanisms
using Playwright
What is the result of implementing these technical solutions in your framework?
framework complexity increases significantly
time and money spent on implementing and testing the new features for finding elements
troubleshooting of find-element issues is more complex
tests get much slower
The outcome is in the end a marginal improvement of the original situation.
Because none of these solutions really work when the locator looks like this
//label[contains(text(),’Price’)]/following-sibling::div//input/../../following-sibling::divWhat is the root cause of the problem?
The html code is not good, the site is not ready for test automation.
We looked into technical solutions so far.
How about using a non-technical solution instead?
Such as talking to the development team and changing the HTML code.
If the HTML code can be improved, the original problem is solved.
If the HTML code cannot be improved, automate as little as possible on the UI and as much as possible on the API.
Thanks for reading.
