Class: Selenium::WebDriver::Options
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Options
show all
- Defined in:
- lib/selenium/webdriver/common/options.rb
Constant Summary
collapse
- W3C_OPTIONS =
%i[browser_name browser_version platform_name accept_insecure_certs page_load_strategy proxy
set_window_rect timeouts unhandled_prompt_behavior strict_file_interactability
web_socket_url].freeze
Class Attribute Summary collapse
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(**opts) ⇒ Options
Returns a new instance of Options.
69
70
71
72
73
74
|
# File 'lib/selenium/webdriver/common/options.rb', line 69
def initialize(**opts)
self.class.set_capabilities
@options = opts
@options[:browser_name] = self.class::BROWSER
end
|
Class Attribute Details
.driver_path ⇒ Object
Returns the value of attribute driver_path.
28
29
30
|
# File 'lib/selenium/webdriver/common/options.rb', line 28
def driver_path
@driver_path
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
67
68
69
|
# File 'lib/selenium/webdriver/common/options.rb', line 67
def options
@options
end
|
Class Method Details
.chrome(**opts) ⇒ Object
30
31
32
|
# File 'lib/selenium/webdriver/common/options.rb', line 30
def chrome(**opts)
Chrome::Options.new(**opts)
end
|
.edge(**opts) ⇒ Object
Also known as:
microsoftedge
43
44
45
|
# File 'lib/selenium/webdriver/common/options.rb', line 43
def edge(**opts)
Edge::Options.new(**opts)
end
|
.firefox(**opts) ⇒ Object
34
35
36
|
# File 'lib/selenium/webdriver/common/options.rb', line 34
def firefox(**opts)
Firefox::Options.new(**opts)
end
|
.ie(**opts) ⇒ Object
Also known as:
internet_explorer
38
39
40
|
# File 'lib/selenium/webdriver/common/options.rb', line 38
def ie(**opts)
IE::Options.new(**opts)
end
|
.safari(**opts) ⇒ Object
48
49
50
|
# File 'lib/selenium/webdriver/common/options.rb', line 48
def safari(**opts)
Safari::Options.new(**opts)
end
|
.set_capabilities ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/selenium/webdriver/common/options.rb', line 52
def set_capabilities
(W3C_OPTIONS + self::CAPABILITIES.keys).each do |key|
next if method_defined? key
define_method key do
@options[key]
end
define_method "#{key}=" do |value|
@options[key] = value
end
end
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
92
93
94
95
96
|
# File 'lib/selenium/webdriver/common/options.rb', line 92
def ==(other)
return false unless other.is_a? self.class
as_json == other.as_json
end
|
#add_option(name, value = nil) ⇒ Object
Add a new option not yet handled by bindings.
87
88
89
90
|
# File 'lib/selenium/webdriver/common/options.rb', line 87
def add_option(name, value = nil)
name, value = name.first if value.nil? && name.is_a?(Hash)
@options[name] = value
end
|
#as_json ⇒ Object
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.
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/selenium/webdriver/common/options.rb', line 104
def as_json(*)
options = @options.dup
w3c_options = process_w3c_options(options)
browser_options = self.class::CAPABILITIES.each_with_object({}) do |(capability_alias, capability_name), hash|
capability_value = options.delete(capability_alias)
hash[capability_name] = capability_value unless capability_value.nil?
end
raise Error::WebDriverError, "These options are not w3c compliant: #{options}" unless options.empty?
browser_options = {self.class::KEY => browser_options} if defined?(self.class::KEY)
process_browser_options(browser_options)
generate_as_json(w3c_options.merge(browser_options))
end
|