Module: Capybara::Lightpanda::Browser::Navigation
- Included in:
- Capybara::Lightpanda::Browser
- Defined in:
- lib/capybara/lightpanda/browser/navigation.rb
Overview
Navigation lifecycle: go_to / back / forward / refresh and the Page.loadEventFired + readyState-polling machinery behind them (the polling fallback is load-bearing — see CLAUDE.md).
Instance Method Summary collapse
- #back ⇒ Object
- #forward ⇒ Object
-
#go_to(url, wait: true) ⇒ Object
(also: #goto)
Navigation with readyState fallback.
- #refresh ⇒ Object (also: #reload)
Instance Method Details
#back ⇒ Object
35 36 37 |
# File 'lib/capybara/lightpanda/browser/navigation.rb', line 35 def back { navigate_history(-1) } end |
#forward ⇒ Object
39 40 41 |
# File 'lib/capybara/lightpanda/browser/navigation.rb', line 39 def forward { navigate_history(+1) } end |
#go_to(url, wait: true) ⇒ Object Also known as: goto
Navigation with readyState fallback.
Lightpanda may never fire Page.loadEventFired on complex JS pages (lightpanda-io/browser#1801, #1832). When the event times out, we poll document.readyState as a fallback.
Page.navigate is sent asynchronously because Lightpanda may not return the command result until the page is fully loaded (unlike Chrome which returns immediately with frameId/loaderId). If we waited synchronously, the readyState fallback would never be reached on pages that fail to fully load.
Uses a single shared deadline so the worst-case wait is 1x timeout, not 2x (lightpanda-io/browser#1849).
24 25 26 27 28 29 30 31 32 |
# File 'lib/capybara/lightpanda/browser/navigation.rb', line 24 def go_to(url, wait: true) enable_page_events if wait wait_for_page_load(url) else page_command("Page.navigate", url: url) end end |
#refresh ⇒ Object Also known as: reload
43 44 45 |
# File 'lib/capybara/lightpanda/browser/navigation.rb', line 43 def refresh { page_command("Page.reload") } end |