Menu

1 / 12

So Enterprise Playwright Suites Are Running the Locator Hierarchy in Reverse

JavaScript in Plain English - Medium·Saqib Jan·14 days ago
#YnNKXaVO
Reading 0:00
15s threshold

So Enterprise Playwright Suites Are Running the Locator Hierarchy in Reverse

Saqib Jan

6 min readJust now

Press enter or click to view image in full size Photo by Israel Andrade on Unsplash

A design system update renames a handful of CSS classes one morning, and by noon dozens of Playwright tests are failing, even though checkout works exactly as it did the day before. Every broken test points at a selector like .btn-primary > span or a long chain of nested div elements. Not one of them says which user action it was supposed to check. That is what a suite built on CSS and XPath costs once it grows, and most enterprise suites are built that way.

Playwright’s documentation recommends the opposite order. It asks tests to find elements the way a user perceives them, starting with getByRole and moving through labels and visible text, with test IDs as an explicit contract between the test and the application.…

Continue reading — create a free account

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