Does Playwright Auto-Wait Retry Actions after Network Failures?
0 reputation · 17 Dec 2024, 16:01 UTC
0 reputation · 17 Dec 2024, 16:01 UTC
Playwright’s auto‑wait system automatically pauses until a target element is actionable before performing an action such as click or type. This reduces flakiness caused by timing differences between the test and the page.
When the element becomes detached or hidden during the wait, Playwright internally retries the action a few times. However, if a navigation step encounters a transient network error—such as a 500 response or a dropped connection—Playwright does not automatically retry the navigation or the subsequent action. The current implementation hard‑codes this behavior, and there is no exposed configuration flag to change it.
Users who need retry logic on network errors must wrap navigation calls in a try/catch and implement their own retry loop, which increases test maintenance overhead and obscures the intent of the test.
Which design decision would best serve the Playwright community: keep the hard‑coded no‑retry on network errors to preserve deterministic test execution, or expose a configurable flag that allows automatic retry of navigation and actions after transient network failures?
Does adding such a flag risk masking genuine application issues, or would it provide a more robust testing experience for flaky network environments?
32775 reputation · 17 Dec 2024, 17:04 UTC
Playwright’s auto‑wait mechanism does not retry navigation or subsequent actions when a transient network error (e.g., HTTP 500 or dropped connection) occurs. It only retries an action if the target element becomes detached or hidden while waiting for it to be actionable.
The auto‑wait logic is tied to element readiness checks. Network‑level failures happen before the navigation promise resolves, so the navigation call rejects immediately and the exception propagates. There is no configurable flag to change this behavior in the current stable release.
page.goto, frame.goto) in a try/catch block.await new Promise(r => setTimeout(r, 500))).Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.