Repository navigation
fix: fill a field once, even when an attempt runs out after the text was sent - #302
CharlieEtienne wants to merge 1 commit into
Conversation
…was sent Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Independent reproduction on 5.2.0 (Playwright 1.63.0, Chromium headless shell 1243, PHP 8.5), in a different app: an Inertia/React login form. Under CPU contention, Measured on our parallel browser suite, with one busy loop per core:
One thing that may deserve a note in the description or the upgrade notes: a fill now gets a single attempt of the configured timeout. The retry loop used to stretch that to about twice the timeout. On a CPU-starved runner, a single fill took up to ~8 s, so suites on the 5 s default can see new |
What happens
fill()andtype()still run throughExecution::waitForExpectation(), in one-second attempts. Playwright's fill selects the field's text, then inserts the value. When an attempt runs out after the insertion was sent (the page is busy, e.g. right after a click that opened it), the next attempt fills again. If that attempt's selection runs before the first insertion lands, both insertions end up in the field.On our CI,
->fill('#answer-remarque', 'À finir demain')right after a click that opens the page leftÀ finir demainÀ finir demainin the field (plugin 5.1.2, Playwright 1.62.1).#269 kept
fillandtypein the loop because they looked idempotent. This race means they are not.The change
fillandtypejoin the methods that are not retried, next toclickandappend. Playwright waits for the field to be visible, enabled and editable within that one call.GuessLocatorchecks[id]and[name]once, then falls back togetByText(). Taken out of the loop as they are, a fill right after the click that reveals its field would wait the whole timeout on that text locator. Avoid retrying side-effecting browser actions #227 ran into this.type()now retries only the lookup, which is read-only, until the field is on the page, then fills once.Tests
Two tests in
FillTest:inputevent holds the page for 1.5 s counts its input events, forfill()andtype(). It counts 2 on5.xand 1 with this change.5.x, and times out iffillandtypeare only added to the list.Whether the text ends up doubled depends on which of the two lands first in the renderer, so the test can't force it. The first test counts the second insertion instead.
The same tests in our app's suite, on 5.1.2 (Playwright 1.62.1, PHP 8.5):
fill/typeadded to the list onlyChecks
composer testpasses locally on macOS with PHP 8.5 and Playwright 1.63.0: Rector, Pint, profanity, 100% type coverage, PHPStan, and 434 tests. Against unchanged5.xsource, the two "fills only once" tests fail with'2'. The test for the revealed field times out whenfillandtypeare only added to the list.🤖 Generated with Claude Code