Repository navigation
Playwright: make waitForText with a CSS context match on innerText, like I.see - #5778
Open
kobenguyent with Copilot wants to merge 2 commits into
Open
kobenguyent with Copilot wants to merge 2 commits into
kobenguyent with Copilot wants to merge 2 commits into
Conversation
Co-authored-by: kobenguyent <7845001+kobenguyent@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix inconsistent assert behavior for text in tests
Playwright: make Oct 31, 2026
waitForText with a CSS context match on innerText, like I.see
kobenguyent
marked this pull request as ready for review
November 1, 2026 05:47
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.
I.waitForTextwith a context compared text differently fromI.seedepending on the locator. For a CSS context it used Playwright'stext=selector, which normalizes whitespace. For an XPath context (including anything built with.at(n)) it usedinnerText. The same text could therefore pass forI.see, fail forI.waitForText, and change result when.at(1)was added to the locator.Changes
lib/helper/Playwright.js(waitForText):locator(${css} >> text=...).this._locate(locator)and readsinnerText ?? textContent, the same extractionproceedSeeuses.waitTimeoutand keeps the existingText "..." was not found on page after N sec.error.test/helper/webapi.js: adds awaitForTextcase usingnew Locator('#text').at(1)as the context.Notes for review
grabTextFromis untouched and still returnstextContent, so the\n 1\n 2\n 3\nresult in the issue's first example persists. Switching it toinnerTextwould change return values for existing users, so I left that for a separate decision..at(1)path on/dynamic. It does not reproduce the span or Bootstrap scenarios from the issue.