From f612dcfea8d6e9e6f396af8562173dd51a2e40ab Mon Sep 17 00:00:00 2001 From: Pushpak Jaiswal <149317014+PUSHPAK-JAISWAL@users.noreply.github.com> Date: Wed, 28 Oct 2026 15:10:51 +0530 Subject: [PATCH 1/8] docs(why): add Why accessibility-first locators? page --- .../why/why-accessibility-first-locators.md | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 docs-site/docs/why/why-accessibility-first-locators.md diff --git a/docs-site/docs/why/why-accessibility-first-locators.md b/docs-site/docs/why/why-accessibility-first-locators.md new file mode 100644 index 0000000..b092512 --- /dev/null +++ b/docs-site/docs/why/why-accessibility-first-locators.md @@ -0,0 +1,134 @@ +--- +description: "Why accessibility-first locators: targeting the accessibility tree (getByRole, getByLabel, getByText) survives CSS rewrites and markup refactors without hiding Selenium." +id: why-accessibility-first-locators +title: Why accessibility-first locators? +sidebar_label: Why accessibility-first locators? +sidebar_position: 4 +--- + +# Why accessibility-first locators? + +Automated tests break for two reasons: real regressions, and brittle selectors. The second kind is wasted time. + +Most Selenium test suites are packed with CSS selectors and XPath expressions tied directly to DOM hierarchies or styling hooks: + +```java +// Brittle: bound to exact tag hierarchy and volatile utility classes +driver.findElement(By.cssSelector("form.auth-form div.input-group > input.email-input")) + .sendKeys("user@example.com"); +driver.findElement(By.cssSelector("form.auth-form div.actions button.btn-primary")) + .click(); +``` + +When frontend developers restructure a component, migrate CSS frameworks (e.g. from Bootstrap to Tailwind), or wrap a field in an extra `