Repository navigation
Conversation
…thin()
waitForEnabled, waitForDisabled, waitForValue and waitNumberOfVisibleElements
called waitForFunction on the helper context, which is a Locator inside
within() and a FrameLocator inside within({ frame }). They now poll
context.locator(selector).evaluateAll(...) until the timeout, so they work in
page, frame and element contexts and only search inside the within element.
A navigation during the wait is retried. The selector goes through
Playwright's engines, so the WebKit "$XPath is not a function" error (codeceptjs#4749)
no longer happens in these functions.
Resolves codeceptjs#4840
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation/Description of the PR
within(),waitForEnabled,waitForDisabled,waitForValueandwaitNumberOfVisibleElementsfail. They callwaitForFunctionon the helper's context, and inside awithinblock that context is a PlaywrightLocator(aFrameLocatorinsidewithin({ frame })), not a page. Before Playwright 1.65 the error iscontext.waitForFunction is not a function. 1.65 addedLocator.waitForFunction, which passes the element as the first argument, so now it fails withTypeError: object is not iterable.context.locator(selector).evaluateAll(...)and poll every 100 ms until the timeout. That works for page, frame and element contexts, and only searches inside thewithinelement, the wayseeandwaitForVisiblealready do. A navigation during the wait doesn't fail it, as withwaitForFunction. The checks and error messages are unchanged. That includeswaitNumberOfVisibleElementstreating "no matches" differently for CSS and XPath, which I left alone.querySelectorAlland the injected$XPathfunction. So these four match the same elementsclickandseedo (open shadow roots included), and the WebKit error from Playwright: WebKit: TypeError: $XPath is not a function. (In '$XPath(null, locator)', '$XPath' is "function $XPath(element, selector) #4749 ($XPath is not a function) no longer happens in them.waitForDetachedwith an XPath locator andwaitForTextwith an XPath context use the samecontext.waitForFunctioncall. I left them out to keep this focused.Applicable helpers:
Applicable plugins:
Type of change
Checklist:
npm run docs)npm run lint)npm test): see belowVerification:
test/helper/Playwright_test.jsand a scenario intest/acceptance/within_test.js. Thewithinand frame tests fail on4.xwith the errors above and pass with the fix. One test navigates in the middle of a wait.test/helper/Playwright_test.json Chromium: 514 passing. The one failure,should see recording traffics, fails on4.xtoo (it expects an image on codecept.io). ThewaitFor*tests also pass on Firefox and WebKit, where4.xfails the existing XPath cases with the Playwright: WebKit: TypeError: $XPath is not a function. (In '$XPath(null, locator)', '$XPath' is "function $XPath(element, selector) #4749 error.@Playwrighton Chromium (also withBROWSER_RESTART=browserandsession), Firefox and WebKit: 125 passed, 2 skipped in each.npm run lint,test:unitandtest:restpass.test:runnerhas 2 failures that also fail on4.x(npm run defneedsbun, and a Testomatio multi-run report test).Written with Claude Code; I reviewed the changes and ran the full suite locally.