Menu

I built self-healing Selenium locators in Java — here's how it works
📰

I built self-healing Selenium locators in Java — here's how it works

DEV Community·Mohammad Saddam Hossain·6 months ago
#ZPrMlNRy
#submit#submitform#matcher#name#article
Reading 0:00
15s threshold

The problem every Selenium team hits

Your test suite was green last week. Today it's failing on 12 tests. The error is always the same:

org.openqa.selenium.TimeoutException: Expected condition failed: waiting for visibility of element located by By.cssSelector: #submit-btn

Enter fullscreen mode

Exit fullscreen mode

You open the app. The button is right there. You inspect it — the id changed from submit-btn to btn-submit . A frontend developer renamed it during a refactor and didn't tell QA.

This is the #1 cause of flaky, high-maintenance Selenium suites. Locators are brittle by nature. The moment the DOM changes, your tests break — even when the feature itself works perfectly.

The standard advice is "use better locators" (data-testid, aria labels). Good advice.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.