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 =
[1024, 768].freeze
Instance Attribute Summary collapse
-
#browser_path ⇒ Object
Returns the value of attribute browser_path.
-
#handshake_timeout ⇒ Object
Returns the value of attribute handshake_timeout.
-
#headless ⇒ Object
Returns the value of attribute headless.
-
#host ⇒ Object
Returns the value of attribute host.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#port ⇒ Object
Returns the value of attribute port.
-
#process_timeout ⇒ Object
Returns the value of attribute process_timeout.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
-
#window_size ⇒ Object
Returns the value of attribute window_size.
- #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.
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/capybara/lightpanda/options.rb', line 29 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 = .fetch(:window_size, DEFAULT_WINDOW_SIZE) @browser_path = [:browser_path] @headless = .fetch(:headless, true) @ws_url = [:ws_url] @logger = parse_logger([:logger]) end |
Instance Attribute Details
#browser_path ⇒ Object
Returns the value of attribute browser_path.
25 26 27 |
# File 'lib/capybara/lightpanda/options.rb', line 25 def browser_path @browser_path end |
#handshake_timeout ⇒ Object
Returns the value of attribute handshake_timeout.
25 26 27 |
# File 'lib/capybara/lightpanda/options.rb', line 25 def handshake_timeout @handshake_timeout end |
#headless ⇒ Object
Returns the value of attribute headless.
25 26 27 |
# File 'lib/capybara/lightpanda/options.rb', line 25 def headless @headless end |
#host ⇒ Object
Returns the value of attribute host.
25 26 27 |
# File 'lib/capybara/lightpanda/options.rb', line 25 def host @host end |
#logger ⇒ Object
Returns the value of attribute logger.
25 26 27 |
# File 'lib/capybara/lightpanda/options.rb', line 25 def logger @logger end |
#port ⇒ Object
Returns the value of attribute port.
25 26 27 |
# File 'lib/capybara/lightpanda/options.rb', line 25 def port @port end |
#process_timeout ⇒ Object
Returns the value of attribute process_timeout.
25 26 27 |
# File 'lib/capybara/lightpanda/options.rb', line 25 def process_timeout @process_timeout end |
#timeout ⇒ Object
Returns the value of attribute timeout.
25 26 27 |
# File 'lib/capybara/lightpanda/options.rb', line 25 def timeout @timeout end |
#window_size ⇒ Object
Returns the value of attribute window_size.
25 26 27 |
# File 'lib/capybara/lightpanda/options.rb', line 25 def window_size @window_size end |
#ws_url ⇒ Object
42 43 44 |
# File 'lib/capybara/lightpanda/options.rb', line 42 def ws_url @ws_url || "ws://#{host}:#{port}/" end |
Instance Method Details
#to_h ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/capybara/lightpanda/options.rb', line 50 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, } h[:ws_url] = @ws_url if @ws_url h end |
#ws_url? ⇒ Boolean
46 47 48 |
# File 'lib/capybara/lightpanda/options.rb', line 46 def ws_url? !@ws_url.nil? end |