Fix: wait for element to be stable fails on infinite animations (#2711)#2773
Open
NajoroRabiaza wants to merge 2 commits into
Open
Fix: wait for element to be stable fails on infinite animations (#2711)#2773NajoroRabiaza wants to merge 2 commits into
NajoroRabiaza wants to merge 2 commits into
Conversation
NivedhaSenthil
requested changes
Apr 20, 2026
| let elem = this; | ||
| return new Promise((resolve, reject) => { | ||
| setTimeout(() => reject(false), 10000); | ||
| setTimeout( |
Member
There was a problem hiding this comment.
Can you please add an unit test covering this case ?
Contributor
Author
There was a problem hiding this comment.
Yes, I have add two unit tests, so one for when the element is stable and one for the infinite animation case
23dfe10 to
54067ed
Compare
…auge#2711) Signed-off-by: NajoroRabiaza <hei.najoro.2@gmail.com>
Signed-off-by: NajoroRabiaza <hei.najoro.2@gmail.com>
54067ed to
7af6ab4
Compare
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 #2711
This PR fixes an issue where actions like click() on elements with infinite CSS animations would not correctly wait for the 10-second timeout and would fail prematurely or proceed unpredictably.
Root Cause
The root cause was a combination of logic flaws in how element stability was checked and how timeouts were communicated back through the Chrome DevTools Protocol (CDP):
isInSamePosition was returning an integer instead of a boolean, confusing the stability logic.
A missing return statement after the initial requestAnimationFrame caused the comparison to happen immediately against the same object.
The 10-second timeout rejected with a primitive false instead of an Error object. In CDP, rejecting with a primitive value swallows the error (resulting in undefined), meaning the Node process never saw the timeout exception.
checkStable was not checking for res.exceptionDetails to propagate the error properly.
Changes Made
Updated isInSamePosition to return a strict boolean (topDiff + leftDiff + bottomDiff + rightDiff === 0).
Added the missing return; statement in waitForElementToBeStable after the first requestAnimationFrame call.
Modified the 10-second timeout to reject with a proper new Error("Element is not stable: still moving after 10000ms").
Added an exceptionDetails check inside checkStable to correctly intercept the timeout error from the browser context and throw it as a standard JavaScript Error in Node.js.