Class: Capybara::Lightpanda::Options

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Options

Returns a new instance of Options.



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/capybara/lightpanda/options.rb', line 33

def initialize(options = {})
  @host = options.fetch(:host, DEFAULT_HOST)
  @port = options.fetch(:port, DEFAULT_PORT)
  @timeout = options.fetch(:timeout, DEFAULT_TIMEOUT)
  @handshake_timeout = options.fetch(:handshake_timeout, DEFAULT_HANDSHAKE_TIMEOUT)
  @process_timeout = options.fetch(:process_timeout, DEFAULT_PROCESS_TIMEOUT)
  @window_size = options.fetch(:window_size, DEFAULT_WINDOW_SIZE)
  @browser_path = options[:browser_path]
  @headless = options.fetch(:headless, true)
  @ws_url = options[:ws_url]
  @logger = parse_logger(options[:logger])
end

Instance Attribute Details

#browser_pathObject

window_size and headless are accepted for Cuprite drop-in compatibility (standard options at driver registration) but are inert: Lightpanda has no rendering engine, so there is nothing to resize, and headless is the only mode it runs in.



29
30
31
# File 'lib/capybara/lightpanda/options.rb', line 29

def browser_path
  @browser_path
end

#handshake_timeoutObject

window_size and headless are accepted for Cuprite drop-in compatibility (standard options at driver registration) but are inert: Lightpanda has no rendering engine, so there is nothing to resize, and headless is the only mode it runs in.



29
30
31
# File 'lib/capybara/lightpanda/options.rb', line 29

def handshake_timeout
  @handshake_timeout
end

#headlessObject

window_size and headless are accepted for Cuprite drop-in compatibility (standard options at driver registration) but are inert: Lightpanda has no rendering engine, so there is nothing to resize, and headless is the only mode it runs in.



29
30
31
# File 'lib/capybara/lightpanda/options.rb', line 29

def headless
  @headless
end

#hostObject

window_size and headless are accepted for Cuprite drop-in compatibility (standard options at driver registration) but are inert: Lightpanda has no rendering engine, so there is nothing to resize, and headless is the only mode it runs in.



29
30
31
# File 'lib/capybara/lightpanda/options.rb', line 29

def host
  @host
end

#loggerObject

window_size and headless are accepted for Cuprite drop-in compatibility (standard options at driver registration) but are inert: Lightpanda has no rendering engine, so there is nothing to resize, and headless is the only mode it runs in.



29
30
31
# File 'lib/capybara/lightpanda/options.rb', line 29

def logger
  @logger
end

#portObject

window_size and headless are accepted for Cuprite drop-in compatibility (standard options at driver registration) but are inert: Lightpanda has no rendering engine, so there is nothing to resize, and headless is the only mode it runs in.



29
30
31
# File 'lib/capybara/lightpanda/options.rb', line 29

def port
  @port
end

#process_timeoutObject

window_size and headless are accepted for Cuprite drop-in compatibility (standard options at driver registration) but are inert: Lightpanda has no rendering engine, so there is nothing to resize, and headless is the only mode it runs in.



29
30
31
# File 'lib/capybara/lightpanda/options.rb', line 29

def process_timeout
  @process_timeout
end

#timeoutObject

window_size and headless are accepted for Cuprite drop-in compatibility (standard options at driver registration) but are inert: Lightpanda has no rendering engine, so there is nothing to resize, and headless is the only mode it runs in.



29
30
31
# File 'lib/capybara/lightpanda/options.rb', line 29

def timeout
  @timeout
end

#window_sizeObject

window_size and headless are accepted for Cuprite drop-in compatibility (standard options at driver registration) but are inert: Lightpanda has no rendering engine, so there is nothing to resize, and headless is the only mode it runs in.



29
30
31
# File 'lib/capybara/lightpanda/options.rb', line 29

def window_size
  @window_size
end

#ws_urlObject



46
47
48
# File 'lib/capybara/lightpanda/options.rb', line 46

def ws_url
  @ws_url || "ws://#{host}:#{port}/"
end

Instance Method Details

#to_hObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/capybara/lightpanda/options.rb', line 54

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

Returns:

  • (Boolean)


50
51
52
# File 'lib/capybara/lightpanda/options.rb', line 50

def ws_url?
  !@ws_url.nil?
end