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: {})


50
51
52
# File 'lib/aranha/selenium/driver_options.rb', line 50

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

Class Method Details

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



11
12
13
14
15
# File 'lib/aranha/selenium/driver_options.rb', line 11

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

  new(source)
end

.defaultAranha::Selenium::DriverOptions



18
19
20
# File 'lib/aranha/selenium/driver_options.rb', line 18

def default
  @default ||= new
end

Instance Method Details

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



73
74
75
# File 'lib/aranha/selenium/driver_options.rb', line 73

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

#to_hHash

Returns:

  • (Hash)


78
79
80
# File 'lib/aranha/selenium/driver_options.rb', line 78

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