-
Notifications
You must be signed in to change notification settings - Fork 5k
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
add abstraction for waitForSelector #10844
Conversation
// Providing a text prop, and optionally a tag or css prop, will use | ||
// xpath to look for an element with the tag that has matching text. | ||
if (locator.css) { | ||
// When providing css prop we use cssToXPath to build a xpath 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.
A majority of our usage of until.elementMatchesText
was using a css selector then waiting until the returned element had matching text. Building an xpath combining CSS selection and text selection more closely mimics Playwright's API (page.waitForSelector('.hello >> text="hi"'). XPath IS slower than CSS selectors, BUT in the case of searching for text, it is not possible without XPath. Combining them into XPath is likely faster than issuing two statements looking for both a CSS selector AND then waiting for text to match.
In the end, though, this entire method (buildLocator) will go away and we will use the much more powerful and expressive playwright selector API.
Builds ready [a3c1468]
Page Load Metrics (645 ± 34 ms)
|
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.
This looks fantastic! This seems like a very good way of abstracting this functionality. I just had a couple of questions about the metamask-ui.spec.js
changes.
a3c1468
to
71870f4
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!
Builds ready [71870f4]
Page Load Metrics (586 ± 43 ms)
|
Adds an abstraction for waitForSelector, a method that exists in the playwright API. This abstraction aims to eventually become a paper-thin abstraction over the playwright version. In the meantime
until
is used behind the scenes to mimick the behavior.Included is a refactor of
metamask-ui.spec.js
which served as a robustness check for the utility.