Repository navigation
fix(node): await the scroll in scroll_to with an element or a location - #363
Open
top-sigrid wants to merge 1 commit into
Open
top-sigrid wants to merge 1 commit into
top-sigrid wants to merge 1 commit into
Conversation
scrollIntoView and scrollTo return a promise in current Chrome. Run without arguments, both scripts took Ferrum 0.20's legacy path, which warns that 0.21 will wait for the promise. Awaiting it takes the path that scroll_to(x, y) and scroll_by already take with their arguments, so all scroll methods wait for the scroll.
top-sigrid
force-pushed
the
fix-await-scroll
branch
from
November 6, 2026 16:24
6a9e7a4 to
5b09d38
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 #362
scroll_to(element)andscroll_to(:top | :bottom | :center)evaluatethis.scrollIntoView(...)andthis.scrollTo(0, ...)without arguments, which Ferrum 0.20 runs the legacy way. Both return a promise in current Chrome, so Ferrum prints its promise deprecation once per script and call site, 6 times per Ruby version in CI on main.Both scripts now
awaitthe promise. A script that awaits takes Ferrum's 0.21 path, which waits for the promise.scroll_to(x, y)andscroll_byalready take that path because they pass named arguments, so all scroll methods now wait for the scroll.The warning suggests
voidinstead. That would silence it too, but leave these two as the only scroll methods that return before the scroll's promise settles.With Ferrum's default browser options on Chrome 156, the promises resolved in every case tried and none rejected: instant and smooth
scrollIntoView, a smooth scroll interrupted by another,scrollToandscrollByon an element, and an element that was detached or removed.On Ferrum main the warning is gone without this change too, and the scroll specs pass with and without it. So this matters for releases that still require Ferrum 0.20.x.
Two specs run
scroll_to(element, align: :bottom)andscroll_to(:bottom)withFERRUM_DEPRECATION_WARNINGS=raiseand fail without the change. With it, on Chrome 156.0.8078.80:FERRUM_DEPRECATION_WARNINGS=raise bundle exec rake: 1810 examples, 0 failures, 16 pending, on Ruby 3.3.3 and on 4.0.9bundle exec rspec -e scrollagainst Ferrum main (6543f61) on Ruby 4.0.9: 25 examples, 0 failures, no deprecationFERRUM_DEPRECATION_WARNINGS=raise