-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add getByTestId in the browser module #4911
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
Conversation
c373455
to
360ac31
Compare
5f024e4
to
e9a2230
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Just had one usability issue while testing locally: I wrote only part of the string thinking that it would be non-exact matching like the other APIs but it wasn't. This is how Playwright does it and I guess it makes sense because this a "code" label and not something shown in the UI or used by accessibility tools but it doesn't feel super consistent with the other APIs (maybe also because I'm testing them one by one 😅)
Are you saying it's not consistent with playwright, or not consistent with the other |
It's consistent with Playwright but not with the other
|
What?
This adds a convenience method on
page
to be able to select on elements with thedata-testid
attribute.Why?
This is part of the story of adding
getBy*
, which makes working with selectors a little easier. We used to have to work with thepage.locator
API providing either aCSS
selector or aXPath
selector if we wanted to get the element by thedata-testid
attribute on an element:Now we can use:
Working with
getBy*
in general is an industry standard in the frontend testing world.Checklist
make check
) and all pass.Checklist: Documentation (only for k6 maintainers and if relevant)
Please do not merge this PR until the following items are filled out.
Related PR(s)/Issue(s)
#4791, #4248