Class: Selenium::WebDriver::IE::Options

Inherits:
Object
  • Object
show all
Defined in:
build/rb/lib/selenium/webdriver/ie/options.rb

Constant Summary collapse

KEY =
'se:ieOptions'
SCROLL_TOP =
0
SCROLL_BOTTOM =
1
CAPABILITIES =
{
  browser_attach_timeout: 'browserAttachTimeout',
  element_scroll_behavior: 'elementScrollBehavior',
  full_page_screenshot: 'ie.enableFullPageScreenshot',
  ensure_clean_session: 'ie.ensureCleanSession',
  file_upload_dialog_timeout: 'ie.fileUploadDialogTimeout',
  force_create_process_api: 'ie.forceCreateProcessApi',
  force_shell_windows_api: 'ie.forceShellWindowsApi',
  ignore_protected_mode_settings: 'ignoreProtectedModeSettings',
  ignore_zoom_level: 'ignoreZoomSetting',
  initial_browser_url: 'initialBrowserUrl',
  native_events: 'nativeEvents',
  persistent_hover: 'enablePersistentHover',
  require_window_focus: 'requireWindowFocus',
  use_per_process_proxy: 'ie.usePerProcessProxy',
  validate_cookie_document_type: 'ie.validateCookieDocumentType'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ Options

Create a new Options instance

Examples:

options = Selenium::WebDriver::IE::Options.new(args: ['--host=127.0.0.1'])
driver = Selenium::WebDriver.for(:ie, options: options)
options = Selenium::WebDriver::IE::Options.new
options.element_scroll_behavior = Selenium::WebDriver::IE::Options::SCROLL_BOTTOM
driver = Selenium::WebDriver.for(:ie, options: options)

Parameters:

  • opts (Hash)

    the pre-defined options

Options Hash (**opts):

  • args (Array<String>)
  • browser_attach_timeout (Integer)
  • element_scroll_behavior (Integer)

    Either SCROLL_TOP or SCROLL_BOTTOM

  • full_page_screenshot (Boolean)
  • ensure_clean_session (Boolean)
  • file_upload_dialog_timeout (Integer)
  • force_create_process_api (Boolean)
  • force_shell_windows_api (Boolean)
  • ignore_protected_mode_settings (Boolean)
  • ignore_zoom_level (Boolean)
  • initial_browser_url (String)
  • native_events (Boolean)
  • persistent_hover (Boolean)
  • require_window_focus (Boolean)
  • use_per_process_proxy (Boolean)
  • validate_cookie_document_type (Boolean)


88
89
90
91
92
# File 'build/rb/lib/selenium/webdriver/ie/options.rb', line 88

def initialize(**opts)
  @args = Set.new(opts.delete(:args) || [])
  @options = opts
  @options[:native_events] = true if @options[:native_events].nil?
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args



55
56
57
# File 'build/rb/lib/selenium/webdriver/ie/options.rb', line 55

def args
  @args
end

#optionsObject (readonly)

Returns the value of attribute options



55
56
57
# File 'build/rb/lib/selenium/webdriver/ie/options.rb', line 55

def options
  @options
end

Instance Method Details

#add_argument(arg) ⇒ Object

Add a command-line argument to use when starting Internet Explorer.

Parameters:

  • arg (String)

    The command-line argument to add



100
101
102
# File 'build/rb/lib/selenium/webdriver/ie/options.rb', line 100

def add_argument(arg)
  @args << arg
end

#add_option(name, value) ⇒ Object

Add a new option not yet handled by these bindings.

Examples:

options = Selenium::WebDriver::IE::Options.new
options.add_option(:foo, 'bar')

Parameters:

  • name (String, Symbol)

    Name of the option

  • value (Boolean, String, Integer)

    Value of the option



115
116
117
# File 'build/rb/lib/selenium/webdriver/ie/options.rb', line 115

def add_option(name, value)
  @options[name] = value
end

#as_jsonObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



123
124
125
126
127
128
129
130
131
132
133
134
# File 'build/rb/lib/selenium/webdriver/ie/options.rb', line 123

def as_json(*)
  opts = {}

  CAPABILITIES.each do |capability_alias, capability_name|
    capability_value = @options.delete(capability_alias)
    opts[capability_name] = capability_value unless capability_value.nil?
  end
  opts['ie.browserCommandLineSwitches'] = @args.to_a.join(' ') if @args.any?
  opts.merge!(@options)

  {KEY => opts}
end