fix(webdriverio): wait longer for late animation frames, and stabilize 3 e2e tests by plum117 · Pull Request #16123 · webdriverio/webdriverio · GitHub
Skip to content

fix(webdriverio): wait longer for late animation frames, and stabilize 3 e2e tests - #16123

Draft
plum117 wants to merge 9 commits into
webdriverio:mainfrom
plum117:fix/e2e-frame-fallback-flakes
Draft

plum117 wants to merge 9 commits into
webdriverio:mainfrom
plum117:fix/e2e-frame-fallback-flakes

Conversation

@plum117

@plum117 plum117 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

Fixes 3 macOS e2e flakes seen on #16118 (run 39050721055).

  • isStable said "stable" for a moving element (Chrome, findElementAgain): isElementStable waits 2 animation frames or 100 ms. On macOS CI Chrome, 25–55 % of 2-frame waits took > 100 ms, so the check ended before the element moved. Now up to 1 s.
  • Scroll event after the click in Firefox (actionClick, 4/4 tries in one job): the pre-scroll of click had the same 2 frames or 100 ms. Now up to 1 s.
  • Index wait 924 ms < 1000 ms (missingListItem): the wait ends on setTimeout (monotonic), the test measured with Date.now(), which can step back. Now performance.now(), same 1000 ms bound.

With normal frames, nothing changes: the 1 s only applies when no frame comes.

How you tested

  • Unit, each new test fails without its change: isElementStable (no frame for 300 ms, the element moves; no frame at all → 1 s), click (frames after 300 ms; no frame at all → 1 s). webdriverio unit tests 3532 pass; test:oxlint passes.

  • e2e, local: actionClick on Firefox and Chrome 21/21, findElementAgain and missingListItem (3/3) on Chrome pass. Clock step simulated with the real Timer: Date.now 927 ms, performance.now 1002 ms.

  • Frame waits measured in CI (probe, fallback 5 s, 16 jobs, run 1, run 2): max 496 ms during a run (macOS Chrome), 1239 ms for the first frame after browser start (Windows Chrome, 1 of 6 jobs), else ≤ 157 ms. Cost: a cross-origin frame that is not rendered waits the full 1 s (4 isStable calls per Chrome job).

  • Unit tests for the touched package(s)

  • Type definition tests (if the public API / command types changed)

  • Smoke or e2e (only if the testrunner, launcher, or a real browser path changed)

Types of changes

  • Polish (an improvement for an existing feature)
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update (improvements to the project's docs)
  • Specification changes (updates to WebDriver command specifications)
  • Internal updates (everything related to internal scripts, governance documentation and CI files)

Checklist

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)
  • I have added proper type definitions for new commands (if appropriate)

Backport Request

  • This change is solely for v10 and doesn't need to be back-ported (v9 has neither 100 ms fallback)
  • Back-ported PR at #XXXXX

🤖 Generated with Claude Code

plum117 and others added 3 commits October 17, 2026 14:17
isElementStable compared two positions after two animation frames or
100 ms. A busy browser can render no frame within 100 ms: the animation
did not move, and isStable said "stable" for a moving element (e2e
findElementAgain "isStable … checks the movement of the new element",
Chrome on macOS CI). Wait up to 1 s; with normal frames nothing changes.

Unit test (fake timers, no frame for 300 ms, the element moves) fails
without the change. Not reproduced in a real browser: a busy main thread
also delays the timer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…refox click

The pre-scroll of a click in Firefox waited for two animation frames or
100 ms. A busy browser can render no frame within 100 ms, so a scroll
event came after the click (e2e actionClick "gives the page its scroll
events before the click in Firefox", 4 of 4 tries in one macOS job).
Wait up to 1 s; with normal frames nothing changes.

Unit tests (fake timers: frames after 300 ms, no frame at all) fail
without the change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sing list item

The test required elapsed >= waitforTimeout (1000 ms) and got 924 ms on
macOS CI. The Timer of a wait rejects when no time is left for another
try, so a wait can end up to one waitforInterval (100 ms in the e2e
config) before its timeout. The unit tests already check that the index
waits once (they count the waits).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wdio-bot wdio-bot added the PR: Bug Fix 🐛 PRs that contain bug fixes label Oct 17, 2026
@pkg-pr-new

pkg-pr-new Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

@plum117
plum117 marked this pull request as ready for review October 17, 2026 18:24
@plum117
plum117 requested a review from a team as a code owner October 17, 2026 18:24
@greptile-apps

greptile-apps Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] Adjusts animation frame wait timeouts in element interaction code.

Fix the missing-index timing assertion before merging; it can still cause e2e failures.

Summary

Gives late animation frames more time before isElementStable and click scrolling fall back.

  • Stability checks wait longer to catch elements that move late.
  • Clicks give late scroll frames time to fire before continuing.
  • The missing-item test measures waits with a steady clock.

Reviews (2) · Last reviewed commit: "test(webdriverio): isElementStable answe..." · Reviewed by Greptile

Comment thread packages/webdriverio/src/scripts/isElementStable.ts
@plum117
plum117 marked this pull request as draft October 17, 2026 18:30
plum117 and others added 2 commits October 17, 2026 14:37
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…comments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@plum117
plum117 force-pushed the fix/e2e-frame-fallback-flakes branch from 69ac097 to 07307ad Compare October 17, 2026 23:12
plum117 and others added 4 commits October 17, 2026 19:22
…otonic clock

The wait timer ends on setTimeout; Date.now() can step back during the wait (927 ms in a simulation, 924 ms in CI).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…hen a test fails

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@plum117
plum117 marked this pull request as ready for review October 17, 2026 23:39
@greptile-apps

greptile-apps Bot commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

@plum117
plum117 marked this pull request as draft October 17, 2026 23:49

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Bug Fix 🐛 PRs that contain bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants