Class: Aranha::Selenium::DriverOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/aranha/selenium/driver_options.rb,
lib/aranha/selenium/driver_options/option.rb

Defined Under Namespace

Classes: Option

Constant Summary collapse

BOOLEAN_OPTIONS =
[OPTION_ACCEPT_INSECURE_CERTS, OPTION_HEADLESS].freeze
DEFAULT_DOWNLOADS_DIR =
::File.join(::Dir.tmpdir, 'aranha_downloads_dir')
DEFAULT_ACCEPT_INSECURE_CERTS =
false
DEFAULT_HEADLESS =
HEADLESS_AUTO
DEFAULT_PROFILE_DIR =
nil
DEFAULT_PROFILE_NAME =
nil
DEFAULT_USER_AGENT =
nil
HEADLESS_AUTO_ENVVAR =
'DISPLAY'
OPTIONS_SANITIZERS =
{
  headless: lambda { |value|
    case value
    when HEADLESS_AUTO then ENV[HEADLESS_AUTO_ENVVAR].blank?
    when HEADLESS_NO then false
    when HEADLESS_YES then true
    else value.to_bool
    end
  }
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_values = {}) ⇒ DriverOptions

Returns a new instance of DriverOptions.

Parameters:

  • user_values (Hash) (defaults to: {})


52
53
54
# File 'lib/aranha/selenium/driver_options.rb', line 52

def initialize(user_values = {})
  user_values.each { |k, v| send("#{k}=", v) }
end

Class Method Details

.assert(source) ⇒ Aranha::Selenium::DriverOptions



13
14
15
16
17
# File 'lib/aranha/selenium/driver_options.rb', line 13

def assert(source)
  return source if source.is_a?(self)

  new(source)
end

.defaultAranha::Selenium::DriverOptions



20
21
22
# File 'lib/aranha/selenium/driver_options.rb', line 20

def default
  @default ||= new
end

Instance Method Details

#merge(other) ⇒ Aranha::Selenium::DriverOptions



75
76
77
# File 'lib/aranha/selenium/driver_options.rb', line 75

def merge(other)
  self.class.assert(to_h.merge(other.to_h))
end

#to_hHash

Returns:

  • (Hash)


80
81
82
# File 'lib/aranha/selenium/driver_options.rb', line 80

def to_h
  options.values.reject { |opt| opt.user_value.nil? }.to_h { |opt| [opt.key, opt.user_value] }
end