Method: Selenium::WebDriver::Firefox::Options#initialize

Defined in:
lib/selenium/webdriver/firefox/options.rb

#initialize(log_level: nil, **opts) ⇒ Options

Create a new Options instance, only for W3C-capable versions of Firefox.

Examples:

options = Selenium::WebDriver::Firefox::Options.new(args: ['--host=127.0.0.1'])
driver = Selenium::WebDriver.for :firefox, options: options

Options Hash (**opts):

  • :binary (String)

    Path to the Firefox executable to use

  • :args (Array<String>)

    List of command-line arguments to use when starting geckodriver

  • :profile (Profile, String)

    Encoded profile string or Profile instance

  • :log_level (String, Symbol)

    Log level for geckodriver

  • :prefs (Hash)

    A hash with each entry consisting of the key of the preference and its value

  • :options (Hash)

    A hash for raw options



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/selenium/webdriver/firefox/options.rb', line 59

def initialize(log_level: nil, **opts)
  @debugger_address = opts.delete(:debugger_address) { true }
  opts[:accept_insecure_certs] = true unless opts.key?(:accept_insecure_certs)

  super(**opts)

  @options[:args] ||= []
  @options[:prefs] ||= {}
  # https://fxdx.dev/deprecating-cdp-support-in-firefox-embracing-the-future-with-webdriver-bidi/.
  # Enable BiDi only
  @options[:prefs]['remote.active-protocols'] = 1
  @options[:env] ||= {}
  @options[:log] ||= {level: log_level} if log_level

  process_profile(@options.delete(:profile))
end