-
-
Notifications
You must be signed in to change notification settings - Fork 751
Description
What are you trying to achieve?
In DOM sometimes we have multiple elements ".item" with a text containing "Add", e.g. "Add", "Add problem" or just a text "Addison Ryan" (a user full name).
When a test clicks on a link (".item") with the text "Add", it can't use locate(".item").withText("Add")
because all "Add*" elements match (and thus any of them can be "randomly" selected).
It would be handy to have a method withTextEquals()
(an analogy to the Playwright helper's method seeTextEquals()
) that selects a locator which's text equals to passed argument.
XPath allows .=
and text()=
, see https://stackoverflow.com/a/34595441/10172701
IMHO .=
is better for our case as it computes string as a concatenation of all strings inside element, so it behaves similar as contains(., ${text})
(used by withText()
)