-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add getByPlaceholder in the browser module #4904
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
84c6eb3
to
db24587
Compare
4b7c297
to
d5337e0
Compare
d5337e0
to
7d3eda9
Compare
2b664ad
to
bc19851
Compare
452dedb
to
5e51b17
Compare
bc19851
to
9629a7a
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
// buildAttributeSelector is a helper method that builds an attribute selector | ||
// for use with the internal:attr engine. It handles quoted strings and | ||
// applies the appropriate suffix for exact or case-insensitive matching. | ||
func (f *Frame) buildAttributeSelector(attrName, attrValue string, opts *GetByBaseOptions) string { |
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.
What is the expectation on this? If this used with high frequency, I expect we can use a strings builder with a bigger capacity and avoiding re-allocating the string in the case the execution joins the isQuoted
branch.
If we need to apply it, then it would require a quick benchmark of buildAttribtuteSelector
func.
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.
I'll work with strings builder, but not in this PR. I've added it as an action item in a catch all issue that I'll work on once all the getBy*
PRs are merged in.
9629a7a
to
bdf1492
Compare
The base branch was changed.
This will be used by a few of the getBy* APIs which are basically wrappers around the attribute engine.
Use buildAttributeSelector in getByAltText and getByPlaceholder.
bdf1492
to
c2e8497
Compare
What?
This adds a convenience method on
page
to be able to select on elements with theplaceholder
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 theplaceholder
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)
#4790, #4248