Skip to content

[Feature]: Add a locator builder method withTextEquals() #4099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mirao opened this issue Jan 2, 2024 · 0 comments · Fixed by #4100
Closed

[Feature]: Add a locator builder method withTextEquals() #4099

mirao opened this issue Jan 2, 2024 · 0 comments · Fixed by #4100

Comments

@mirao
Copy link
Contributor

mirao commented Jan 2, 2024

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())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant