Method: Selenium::WebDriver::Chromium::Options#initialize

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

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

Create a new Options instance.

Examples:

options = Selenium::WebDriver::Chrome::Options.new(args: ['start-maximized', 'user-data-dir=/tmp/temp_profile'])
driver = Selenium::WebDriver.for(:chrome, options: options)

Parameters:

  • profile (Profile) (defaults to: nil)

    An instance of a Chrome::Profile Class

  • opts (Hash)

    the pre-defined options to create the Chrome::Options with

Options Hash (**opts):

  • encoded_extensions (Array)

    List of extensions that do not need to be Base64 encoded

  • args (Array<String>)

    List of command-line arguments to use when starting Chrome

  • binary (String)

    Path to the Chrome executable to use

  • prefs (Hash)

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

  • extensions (Array<String>)

    A list of paths to (.crx) Chrome extensions to install on startup

  • options (Hash)

    A hash for raw options

  • emulation (Hash)

    A hash for raw emulation options

  • local_state (Hash)

    A hash for the Local State file in the user data folder

  • detach (Boolean)

    whether browser is closed when the driver is sent the quit command

  • debugger_address (String)

    address of a Chrome debugger server to connect to

  • exclude_switches (Array<String>)

    command line switches to exclude

  • minidump_path (String)

    Directory to store Chrome minidumps (linux only)

  • perf_logging_prefs (Hash)

    A hash for performance logging preferences

  • window_types (Array<String>)

    A list of window types to appear in the list of window handles


70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/selenium/webdriver/chromium/options.rb', line 70

def initialize(profile: nil, **opts)
  super(**opts)

  @profile = profile

  @options = {args: [],
              prefs: {},
              emulation: {},
              extensions: [],
              local_state: {},
              exclude_switches: [],
              perf_logging_prefs: {},
              window_types: []}.merge(@options)

  @logging_prefs = options.delete(:logging_prefs) || {}
  @encoded_extensions = @options.delete(:encoded_extensions) || []
  @extensions = []
  @options.delete(:extensions).each { |ext| validate_extension(ext) }
end