Repository navigation
feat(page): add wait_for_navigation and wait_for_navigation! for a navigation a block starts - #679
Merged
Merged
Conversation
…vigation a block starts
Page#command(wait:) already waited for a navigation its command started, but only for commands Ferrum sends itself,
like a click. A navigation started from JavaScript, e.g. `node.evaluate("this.click()")`, had no way to be waited for:
wait_for_reload resets the navigation event after the fact, so it can miss one that already started.
wait_for_navigation(wait) { } resets the event, runs the block, watches `wait` seconds for a navigation and waits for
it to finish within the page timeout, returning false if it doesn't. wait_for_navigation! raises TimeoutError instead.
Page#command(wait:) now uses it.
route
force-pushed
the
feat/wait-for-navigation
branch
from
October 25, 2026 18:14
3bb4c2c to
da08189
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.
Page#command(wait:)already waits for a navigation its command starts, which is how a click waits for the next page. But that only covers commands Ferrum sends itself. A navigation started from JavaScript, such asnode.evaluate("this.click()")on a link, had no way to be waited for:wait_for_reloadresets the navigation event after the block has run, so it can miss a navigation that has already started.wait_for_navigation(wait = 0.1) { }resets the event, runs the block, watcheswaitseconds for a navigation, and waits for it to finish within the page timeout. It returnsfalseif it doesn't,trueotherwise, including when nothing navigates.waitdefaults toFERRUM_CLICK_WAIT, likeclick.wait_for_navigation! { }raisesFerrum::TimeoutErrorinstead, the same split asnetwork.wait_for_idleandwait_for_idle!.Page#command(wait:)now useswait_for_navigation!, so it behaves as before.Browser, with YARD, RBS and a section indocs/3-navigation.md.The specs check that the block's navigation finished by recording a load event that follows the navigation, and they fail against a version that only runs the block.
This also gives the deprecated
evaluate_on(wait:)a replacement for #673, which removes it in 0.21.