Class: Selenium::WebDriver::Edge::Options

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**opts) ⇒ Options

Create a new Options instance for Edge.

Examples:

options = Selenium::WebDriver::Edge::Options.new(in_private: true)
driver = Selenium::WebDriver.for :edge, options: options

Parameters:

  • opts (Hash)

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

Options Hash (**opts):

  • :in_private (Boolean)

    Start in private mode. Default is false

  • :extension_paths (Array<String>)

    A list of full paths to extensions to install on startup

  • :start_page (String)

    Default page to start with

See Also:


42
43
44
45
46
# File 'lib/selenium/webdriver/edge/options.rb', line 42

def initialize(**opts)
  @in_private = opts.delete(:in_private) || false
  @extension_paths = opts.delete(:extension_paths) || []
  @start_page = opts.delete(:start_page)
end

Instance Attribute Details

#extension_pathsObject (readonly)

Returns the value of attribute extension_paths


25
26
27
# File 'lib/selenium/webdriver/edge/options.rb', line 25

def extension_paths
  @extension_paths
end

#in_privateObject

Returns the value of attribute in_private


24
25
26
# File 'lib/selenium/webdriver/edge/options.rb', line 24

def in_private
  @in_private
end

#start_pageObject

Returns the value of attribute start_page


24
25
26
# File 'lib/selenium/webdriver/edge/options.rb', line 24

def start_page
  @start_page
end

Instance Method Details

#add_extension_path(path) ⇒ Object

Add an extension by local path.

Examples:

options = Selenium::WebDriver::Edge::Options.new
options.add_extension_path('C:\path\to\extension')

Parameters:

  • path (String)

    The local path to the extension folder

Raises:


58
59
60
61
62
# File 'lib/selenium/webdriver/edge/options.rb', line 58

def add_extension_path(path)
  raise Error::WebDriverError, "could not find extension at #{path.inspect}" unless File.directory?(path)

  @extension_paths << path
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.


68
69
70
71
72
73
74
75
76
# File 'lib/selenium/webdriver/edge/options.rb', line 68

def as_json(*)
  opts = {}

  opts['ms:inPrivate'] = true if @in_private
  opts['ms:extensionPaths'] = @extension_paths if @extension_paths.any?
  opts['ms:startPage'] = @start_page if @start_page

  opts
end