Method: Playwright::Page#expect_navigation
- Defined in:
- lib/playwright_api/page.rb
#expect_navigation(timeout: nil, url: nil, waitUntil: nil, &block) ⇒ Object
Waits for the main frame navigation and returns the main resource response. In case of multiple redirects, the navigation will resolve with the response of the last redirect. In case of navigation to a different anchor or navigation due to History API usage, the navigation will resolve with ‘null`.
This resolves when the page navigates to a new URL or reloads. It is useful for when you run code which will indirectly cause the page to navigate. e.g. The click target has an ‘onclick` handler that triggers navigation from a `setTimeout`. Consider this example:
“‘python sync with page.expect_navigation():
page.click("a.delayed-navigation") # clicking the link will indirectly cause a navigation
# Resolves after navigation has finished “‘
> NOTE: Usage of the [History API](developer.mozilla.org/en-US/docs/Web/API/History_API) to change the URL is considered a navigation.
Shortcut for main frame’s [‘method: Frame.waitForNavigation`].
1267 1268 1269 |
# File 'lib/playwright_api/page.rb', line 1267 def (timeout: nil, url: nil, waitUntil: nil, &block) wrap_impl(@impl.(timeout: unwrap_impl(timeout), url: unwrap_impl(url), waitUntil: unwrap_impl(waitUntil), &wrap_block_call(block))) end |