-
Notifications
You must be signed in to change notification settings - Fork 96
Description
Hey thanks for the lib I love it 👋
Currently, this library is modeled closely after the Selenium API which is great because we can do anything we want, the API is clear and the By selectors are minimal so we don't get lost. But it often leads to tests that are tightly coupled to implementation details. It encourages interacting with the UI in ways that might not reflect how real users experience the application. As a result, tests can become brittle and hard to maintain, frequently breaking with internal refactors that don’t affect user-facing behavior.
I’d like to propose you to consider adding a 2 APIs more oriented around how users actually interact with applications. A strong inspiration for this is the DOM Testing Library, which is super handy.
Would you be interested in integrating the following APIs or something alike:
driver.find(By::Text("Some text the user should interact with"))
=> matching <div>Some text the user should interact with"<div>, <span>Some text the user should interact with<span>, basically any text inside an element
ref
driver.find(By::LabelText("Some text the user should interact with"))
=> matching element linked or inside to <Label>, aria-label using for and aria-labelledby
ref
It is already possible to implement that with XPath (By::XPath("//*[contains(text(),'Some text the user should interact with"')]")) but it makes noise so I think this kind of APIs can really improve readability and help developers focusing more on what their application do more than how it is implemented.
available to discuss or code it up :)