Class: Capybara::Lightpanda::Options
- Inherits:
-
Object
- Object
- Capybara::Lightpanda::Options
- Defined in:
- lib/capybara/lightpanda/options.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
ENV.fetch("LIGHTPANDA_DEFAULT_TIMEOUT", 15).to_i
- DEFAULT_PROCESS_TIMEOUT =
ENV.fetch("LIGHTPANDA_PROCESS_TIMEOUT", 10).to_i
- DEFAULT_HANDSHAKE_TIMEOUT =
Bounded budget for the WebSocket TCP+Upgrade handshake. Distinct from
timeout(per-CDP-command budget) because a handshake either succeeds in a few hundred ms or won't — bleeding the full command budget into it just delays the eventual failure. ENV.fetch("LIGHTPANDA_HANDSHAKE_TIMEOUT", 5).to_i
- DEFAULT_HOST =
"127.0.0.1"- DEFAULT_PORT =
0 = OS-assigned ephemeral port. Lightpanda logs the address it actually bound and Process#wait_for_ready parses it back, so every driver instance — including each parallel test worker — gets its own free port with zero configuration. Pin a fixed port via
Capybara::Lightpanda.configure { |c| c.port = 9222 }when external tooling needs a known address. 0- DEFAULT_WINDOW_SIZE =
Mirrors Lightpanda's own
Viewport.default(1920x1080) rather than Cuprite's 1024x768. window_size is applied for real now (see below), so a 1024x768 default would silently shrink the viewport of every existing suite and flip@mediabranches under them. Matching the browser's native default keepswindow_sizetruthful AND leaves default behavior byte-identical to before it was wired up. [1920, 1080].freeze
Instance Attribute Summary collapse
-
#browser_path ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via Browser#set_viewport on every create_page.
-
#handshake_timeout ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via Browser#set_viewport on every create_page.
-
#headless ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via Browser#set_viewport on every create_page.
-
#host ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via Browser#set_viewport on every create_page.
-
#logger ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via Browser#set_viewport on every create_page.
-
#port ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via Browser#set_viewport on every create_page.
-
#process_timeout ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via Browser#set_viewport on every create_page.
-
#raise_on_unhandled_modal ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via Browser#set_viewport on every create_page.
-
#save_path ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via Browser#set_viewport on every create_page.
-
#timeout ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via Browser#set_viewport on every create_page.
-
#window_size ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via Browser#set_viewport on every create_page.
- #ws_url ⇒ Object
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Options
constructor
A new instance of Options.
- #to_h ⇒ Object
- #ws_url? ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ Options
Returns a new instance of Options.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/capybara/lightpanda/options.rb', line 55 def initialize( = {}) @host = .fetch(:host, DEFAULT_HOST) @port = .fetch(:port, DEFAULT_PORT) @timeout = .fetch(:timeout, DEFAULT_TIMEOUT) @handshake_timeout = .fetch(:handshake_timeout, DEFAULT_HANDSHAKE_TIMEOUT) @process_timeout = .fetch(:process_timeout, DEFAULT_PROCESS_TIMEOUT) @window_size = validate_window_size(.fetch(:window_size, DEFAULT_WINDOW_SIZE)) @browser_path = [:browser_path] @headless = .fetch(:headless, true) @save_path = [:save_path] @raise_on_unhandled_modal = .fetch(:raise_on_unhandled_modal, false) @ws_url = [:ws_url] @logger = parse_logger([:logger]) end |
Instance Attribute Details
#browser_path ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via
Browser#set_viewport on every create_page. This is a JS-visible
viewport only — it sets window.innerWidth/innerHeight and the viewport
that matchMedia / @media evaluate against, so responsive branches
resolve at the size you ask for. It is NOT real layout: Lightpanda has
no rendering engine, so getBoundingClientRect stays synthetic and
nothing reflows. Sizing down will not make an off-viewport element
report as obscured.
headless is accepted for Cuprite drop-in compatibility but inert —
headless is the only mode Lightpanda runs in.
save_path: directory for downloaded files (Cuprite parity). nil falls
back to Capybara.save_path at create_page time; downloads stay off when
both are nil (Browser#create_page only opts in when a path exists).
raise_on_unhandled_modal: a JS dialog that opens with no
accept_modal/dismiss_modal pre-arm in flight is resolved by Lightpanda's
silent default (confirm → cancel, prompt → null, alert → dismissed), so
a runaway confirm cancels the action and the spec can still pass. false
(default, Cuprite parity) warns on stderr; true raises
UnhandledModalError from the action that opened it.
50 51 52 |
# File 'lib/capybara/lightpanda/options.rb', line 50 def browser_path @browser_path end |
#handshake_timeout ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via
Browser#set_viewport on every create_page. This is a JS-visible
viewport only — it sets window.innerWidth/innerHeight and the viewport
that matchMedia / @media evaluate against, so responsive branches
resolve at the size you ask for. It is NOT real layout: Lightpanda has
no rendering engine, so getBoundingClientRect stays synthetic and
nothing reflows. Sizing down will not make an off-viewport element
report as obscured.
headless is accepted for Cuprite drop-in compatibility but inert —
headless is the only mode Lightpanda runs in.
save_path: directory for downloaded files (Cuprite parity). nil falls
back to Capybara.save_path at create_page time; downloads stay off when
both are nil (Browser#create_page only opts in when a path exists).
raise_on_unhandled_modal: a JS dialog that opens with no
accept_modal/dismiss_modal pre-arm in flight is resolved by Lightpanda's
silent default (confirm → cancel, prompt → null, alert → dismissed), so
a runaway confirm cancels the action and the spec can still pass. false
(default, Cuprite parity) warns on stderr; true raises
UnhandledModalError from the action that opened it.
50 51 52 |
# File 'lib/capybara/lightpanda/options.rb', line 50 def handshake_timeout @handshake_timeout end |
#headless ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via
Browser#set_viewport on every create_page. This is a JS-visible
viewport only — it sets window.innerWidth/innerHeight and the viewport
that matchMedia / @media evaluate against, so responsive branches
resolve at the size you ask for. It is NOT real layout: Lightpanda has
no rendering engine, so getBoundingClientRect stays synthetic and
nothing reflows. Sizing down will not make an off-viewport element
report as obscured.
headless is accepted for Cuprite drop-in compatibility but inert —
headless is the only mode Lightpanda runs in.
save_path: directory for downloaded files (Cuprite parity). nil falls
back to Capybara.save_path at create_page time; downloads stay off when
both are nil (Browser#create_page only opts in when a path exists).
raise_on_unhandled_modal: a JS dialog that opens with no
accept_modal/dismiss_modal pre-arm in flight is resolved by Lightpanda's
silent default (confirm → cancel, prompt → null, alert → dismissed), so
a runaway confirm cancels the action and the spec can still pass. false
(default, Cuprite parity) warns on stderr; true raises
UnhandledModalError from the action that opened it.
50 51 52 |
# File 'lib/capybara/lightpanda/options.rb', line 50 def headless @headless end |
#host ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via
Browser#set_viewport on every create_page. This is a JS-visible
viewport only — it sets window.innerWidth/innerHeight and the viewport
that matchMedia / @media evaluate against, so responsive branches
resolve at the size you ask for. It is NOT real layout: Lightpanda has
no rendering engine, so getBoundingClientRect stays synthetic and
nothing reflows. Sizing down will not make an off-viewport element
report as obscured.
headless is accepted for Cuprite drop-in compatibility but inert —
headless is the only mode Lightpanda runs in.
save_path: directory for downloaded files (Cuprite parity). nil falls
back to Capybara.save_path at create_page time; downloads stay off when
both are nil (Browser#create_page only opts in when a path exists).
raise_on_unhandled_modal: a JS dialog that opens with no
accept_modal/dismiss_modal pre-arm in flight is resolved by Lightpanda's
silent default (confirm → cancel, prompt → null, alert → dismissed), so
a runaway confirm cancels the action and the spec can still pass. false
(default, Cuprite parity) warns on stderr; true raises
UnhandledModalError from the action that opened it.
50 51 52 |
# File 'lib/capybara/lightpanda/options.rb', line 50 def host @host end |
#logger ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via
Browser#set_viewport on every create_page. This is a JS-visible
viewport only — it sets window.innerWidth/innerHeight and the viewport
that matchMedia / @media evaluate against, so responsive branches
resolve at the size you ask for. It is NOT real layout: Lightpanda has
no rendering engine, so getBoundingClientRect stays synthetic and
nothing reflows. Sizing down will not make an off-viewport element
report as obscured.
headless is accepted for Cuprite drop-in compatibility but inert —
headless is the only mode Lightpanda runs in.
save_path: directory for downloaded files (Cuprite parity). nil falls
back to Capybara.save_path at create_page time; downloads stay off when
both are nil (Browser#create_page only opts in when a path exists).
raise_on_unhandled_modal: a JS dialog that opens with no
accept_modal/dismiss_modal pre-arm in flight is resolved by Lightpanda's
silent default (confirm → cancel, prompt → null, alert → dismissed), so
a runaway confirm cancels the action and the spec can still pass. false
(default, Cuprite parity) warns on stderr; true raises
UnhandledModalError from the action that opened it.
50 51 52 |
# File 'lib/capybara/lightpanda/options.rb', line 50 def logger @logger end |
#port ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via
Browser#set_viewport on every create_page. This is a JS-visible
viewport only — it sets window.innerWidth/innerHeight and the viewport
that matchMedia / @media evaluate against, so responsive branches
resolve at the size you ask for. It is NOT real layout: Lightpanda has
no rendering engine, so getBoundingClientRect stays synthetic and
nothing reflows. Sizing down will not make an off-viewport element
report as obscured.
headless is accepted for Cuprite drop-in compatibility but inert —
headless is the only mode Lightpanda runs in.
save_path: directory for downloaded files (Cuprite parity). nil falls
back to Capybara.save_path at create_page time; downloads stay off when
both are nil (Browser#create_page only opts in when a path exists).
raise_on_unhandled_modal: a JS dialog that opens with no
accept_modal/dismiss_modal pre-arm in flight is resolved by Lightpanda's
silent default (confirm → cancel, prompt → null, alert → dismissed), so
a runaway confirm cancels the action and the spec can still pass. false
(default, Cuprite parity) warns on stderr; true raises
UnhandledModalError from the action that opened it.
50 51 52 |
# File 'lib/capybara/lightpanda/options.rb', line 50 def port @port end |
#process_timeout ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via
Browser#set_viewport on every create_page. This is a JS-visible
viewport only — it sets window.innerWidth/innerHeight and the viewport
that matchMedia / @media evaluate against, so responsive branches
resolve at the size you ask for. It is NOT real layout: Lightpanda has
no rendering engine, so getBoundingClientRect stays synthetic and
nothing reflows. Sizing down will not make an off-viewport element
report as obscured.
headless is accepted for Cuprite drop-in compatibility but inert —
headless is the only mode Lightpanda runs in.
save_path: directory for downloaded files (Cuprite parity). nil falls
back to Capybara.save_path at create_page time; downloads stay off when
both are nil (Browser#create_page only opts in when a path exists).
raise_on_unhandled_modal: a JS dialog that opens with no
accept_modal/dismiss_modal pre-arm in flight is resolved by Lightpanda's
silent default (confirm → cancel, prompt → null, alert → dismissed), so
a runaway confirm cancels the action and the spec can still pass. false
(default, Cuprite parity) warns on stderr; true raises
UnhandledModalError from the action that opened it.
50 51 52 |
# File 'lib/capybara/lightpanda/options.rb', line 50 def process_timeout @process_timeout end |
#raise_on_unhandled_modal ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via
Browser#set_viewport on every create_page. This is a JS-visible
viewport only — it sets window.innerWidth/innerHeight and the viewport
that matchMedia / @media evaluate against, so responsive branches
resolve at the size you ask for. It is NOT real layout: Lightpanda has
no rendering engine, so getBoundingClientRect stays synthetic and
nothing reflows. Sizing down will not make an off-viewport element
report as obscured.
headless is accepted for Cuprite drop-in compatibility but inert —
headless is the only mode Lightpanda runs in.
save_path: directory for downloaded files (Cuprite parity). nil falls
back to Capybara.save_path at create_page time; downloads stay off when
both are nil (Browser#create_page only opts in when a path exists).
raise_on_unhandled_modal: a JS dialog that opens with no
accept_modal/dismiss_modal pre-arm in flight is resolved by Lightpanda's
silent default (confirm → cancel, prompt → null, alert → dismissed), so
a runaway confirm cancels the action and the spec can still pass. false
(default, Cuprite parity) warns on stderr; true raises
UnhandledModalError from the action that opened it.
50 51 52 |
# File 'lib/capybara/lightpanda/options.rb', line 50 def raise_on_unhandled_modal @raise_on_unhandled_modal end |
#save_path ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via
Browser#set_viewport on every create_page. This is a JS-visible
viewport only — it sets window.innerWidth/innerHeight and the viewport
that matchMedia / @media evaluate against, so responsive branches
resolve at the size you ask for. It is NOT real layout: Lightpanda has
no rendering engine, so getBoundingClientRect stays synthetic and
nothing reflows. Sizing down will not make an off-viewport element
report as obscured.
headless is accepted for Cuprite drop-in compatibility but inert —
headless is the only mode Lightpanda runs in.
save_path: directory for downloaded files (Cuprite parity). nil falls
back to Capybara.save_path at create_page time; downloads stay off when
both are nil (Browser#create_page only opts in when a path exists).
raise_on_unhandled_modal: a JS dialog that opens with no
accept_modal/dismiss_modal pre-arm in flight is resolved by Lightpanda's
silent default (confirm → cancel, prompt → null, alert → dismissed), so
a runaway confirm cancels the action and the spec can still pass. false
(default, Cuprite parity) warns on stderr; true raises
UnhandledModalError from the action that opened it.
50 51 52 |
# File 'lib/capybara/lightpanda/options.rb', line 50 def save_path @save_path end |
#timeout ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via
Browser#set_viewport on every create_page. This is a JS-visible
viewport only — it sets window.innerWidth/innerHeight and the viewport
that matchMedia / @media evaluate against, so responsive branches
resolve at the size you ask for. It is NOT real layout: Lightpanda has
no rendering engine, so getBoundingClientRect stays synthetic and
nothing reflows. Sizing down will not make an off-viewport element
report as obscured.
headless is accepted for Cuprite drop-in compatibility but inert —
headless is the only mode Lightpanda runs in.
save_path: directory for downloaded files (Cuprite parity). nil falls
back to Capybara.save_path at create_page time; downloads stay off when
both are nil (Browser#create_page only opts in when a path exists).
raise_on_unhandled_modal: a JS dialog that opens with no
accept_modal/dismiss_modal pre-arm in flight is resolved by Lightpanda's
silent default (confirm → cancel, prompt → null, alert → dismissed), so
a runaway confirm cancels the action and the spec can still pass. false
(default, Cuprite parity) warns on stderr; true raises
UnhandledModalError from the action that opened it.
50 51 52 |
# File 'lib/capybara/lightpanda/options.rb', line 50 def timeout @timeout end |
#window_size ⇒ Object
window_size drives Emulation.setDeviceMetricsOverride via
Browser#set_viewport on every create_page. This is a JS-visible
viewport only — it sets window.innerWidth/innerHeight and the viewport
that matchMedia / @media evaluate against, so responsive branches
resolve at the size you ask for. It is NOT real layout: Lightpanda has
no rendering engine, so getBoundingClientRect stays synthetic and
nothing reflows. Sizing down will not make an off-viewport element
report as obscured.
headless is accepted for Cuprite drop-in compatibility but inert —
headless is the only mode Lightpanda runs in.
save_path: directory for downloaded files (Cuprite parity). nil falls
back to Capybara.save_path at create_page time; downloads stay off when
both are nil (Browser#create_page only opts in when a path exists).
raise_on_unhandled_modal: a JS dialog that opens with no
accept_modal/dismiss_modal pre-arm in flight is resolved by Lightpanda's
silent default (confirm → cancel, prompt → null, alert → dismissed), so
a runaway confirm cancels the action and the spec can still pass. false
(default, Cuprite parity) warns on stderr; true raises
UnhandledModalError from the action that opened it.
50 51 52 |
# File 'lib/capybara/lightpanda/options.rb', line 50 def window_size @window_size end |
#ws_url ⇒ Object
70 71 72 |
# File 'lib/capybara/lightpanda/options.rb', line 70 def ws_url @ws_url || "ws://#{host}:#{port}/" end |
Instance Method Details
#to_h ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/capybara/lightpanda/options.rb', line 78 def to_h h = { host: host, port: port, timeout: timeout, handshake_timeout: handshake_timeout, process_timeout: process_timeout, window_size: window_size, browser_path: browser_path, headless: headless, logger: logger, save_path: save_path, raise_on_unhandled_modal: raise_on_unhandled_modal, } h[:ws_url] = @ws_url if @ws_url h end |
#ws_url? ⇒ Boolean
74 75 76 |
# File 'lib/capybara/lightpanda/options.rb', line 74 def ws_url? !@ws_url.nil? end |