Repository navigation
fix(playwright): don't block in see() when a matched element is removed - #5746
Merged
DavertMik merged 2 commits intoOct 11, 2026
Merged
Conversation
proceedSee() read the text of each element matched by the context via Locator.innerText(), which auto-waits for the element to be attached. If one of the elements was removed between all() and innerText(), the step blocked for the full helper timeout and failed, even when another matched element contained the expected text. Read the texts with evaluateAll(), which doesn't wait, so a removed element contributes no text. Fixes codeceptjs#5745 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ents Reading texts with evaluateAll() left two false passes in proceedSee(): - When every matched element was removed after it was located, no text was read, so seeTextEquals() asserted nothing and passed. Report the element as not found instead. - Non-HTML elements such as SVG have no innerText and were read as empty text, so dontSee() passed on text that was on the page. Fall back to textContent. Refs codeceptjs#5745 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
thank you! good catch! |
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.
Fixes #5745
Problem
I.see(text, context)reads the text of every element matched bycontextviaLocator.innerText(). Locators returned by.all()auto-wait for the element to be attached, so if one matched element is removed between.all()andinnerText(), the step blocks for the full helpertimeoutand fails withinnerText: Timeout ...ms exceeded, even when another matched element contains the expected text. Unlike #5739, this does not need--verbose/--debug.A typical case is toast messages: an old toast auto-closes while the step checks a new one.
Fix
proceedSee()reads the texts withLocator.evaluateAll(), which does not wait, so a removed element contributes no text. This affectssee,dontSeeandseeTextEqualswith a context.Two related cases are handled so that the check can't pass by accident:
seeTextEqualswould pass silently).<text>, which have noinnerText, the text falls back totextContent. PreviouslyLocator.innerText()threw on such elements.Test
Added regression tests to
test/helper/Playwright_test.js:Locator.all()resolves:seeon the remaining element anddontSeeon the removed one finish in under 1 s. Both fail without the fix (timeout).seeTextEqualsfails with "was not found" in under 1 s.see/dontSeeon an SVG<text>element.🤖 Generated with Claude Code