Class: Selenium::WebDriver::Remote::Capabilities Private
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Remote::Capabilities
- Defined in:
- lib/selenium/webdriver/remote/capabilities.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Specification of the desired and/or actual capabilities of the browser that the server is being asked to create.
Constant Summary collapse
- DEFAULTS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ :browser_name => "", :version => "", :platform => :any, :javascript_enabled => false, :css_selectors_enabled => false, :takes_screenshot => false, :native_events => false, :rotatable => false, :firefox_profile => nil, :proxy => nil }
Class Method Summary collapse
- .android(opts = {}) ⇒ Object private
- .chrome(opts = {}) ⇒ Object private
- .edge(opts = {}) ⇒ Object private
- .firefox(opts = {}) ⇒ Object private
- .htmlunit(opts = {}) ⇒ Object private
- .htmlunitwithjs(opts = {}) ⇒ Object private
- .internet_explorer(opts = {}) ⇒ Object (also: ie) private
- .ipad(opts = {}) ⇒ Object private
- .iphone(opts = {}) ⇒ Object private
- .json_create(data) ⇒ Object private
- .phantomjs(opts = {}) ⇒ Object private
- .safari(opts = {}) ⇒ Object private
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?) private
- #[](key) ⇒ Object private
-
#[]=(key, value) ⇒ Object
private
Allows setting arbitrary capabilities.
- #as_json(opts = nil) ⇒ Object private
-
#initialize(opts = {}) ⇒ Capabilities
constructor
Firefox-specific options:.
- #merge!(other) ⇒ Object private
- #proxy=(proxy) ⇒ Object private
- #to_json(*args) ⇒ Object private
Constructor Details
#initialize(opts = {}) ⇒ Capabilities
Firefox-specific options:
196 197 198 199 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 196 def initialize(opts = {}) @capabilities = DEFAULTS.merge(opts) self.proxy = opts.delete(:proxy) end |
Class Method Details
.android(opts = {}) ⇒ 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.
63 64 65 66 67 68 69 70 71 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 63 def android(opts = {}) new({ :browser_name => "android", :platform => :android, :javascript_enabled => true, :rotatable => true, :takes_screenshot => true }.merge(opts)) end |
.chrome(opts = {}) ⇒ 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.
73 74 75 76 77 78 79 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 73 def chrome(opts = {}) new({ :browser_name => "chrome", :javascript_enabled => true, :css_selectors_enabled => true }.merge(opts)) end |
.edge(opts = {}) ⇒ 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.
81 82 83 84 85 86 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 81 def edge(opts = {}) new({ :browser_name => "MicrosoftEdge", :platform => :windows, }.merge(opts)) end |
.firefox(opts = {}) ⇒ 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.
88 89 90 91 92 93 94 95 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 88 def firefox(opts = {}) new({ :browser_name => "firefox", :javascript_enabled => true, :takes_screenshot => true, :css_selectors_enabled => true }.merge(opts)) end |
.htmlunit(opts = {}) ⇒ 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.
97 98 99 100 101 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 97 def htmlunit(opts = {}) new({ :browser_name => "htmlunit" }.merge(opts)) end |
.htmlunitwithjs(opts = {}) ⇒ 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.
103 104 105 106 107 108 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 103 def htmlunitwithjs(opts = {}) new({ :browser_name => "htmlunit", :javascript_enabled => true }.merge(opts)) end |
.internet_explorer(opts = {}) ⇒ Object Also known as: ie
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.
110 111 112 113 114 115 116 117 118 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 110 def internet_explorer(opts = {}) new({ :browser_name => "internet explorer", :platform => :windows, :takes_screenshot => true, :css_selectors_enabled => true, :native_events => true }.merge(opts)) end |
.ipad(opts = {}) ⇒ 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.
129 130 131 132 133 134 135 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 129 def ipad(opts = {}) new({ :browser_name => "iPad", :platform => :mac, :javascript_enabled => true }.merge(opts)) end |
.iphone(opts = {}) ⇒ 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.
121 122 123 124 125 126 127 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 121 def iphone(opts = {}) new({ :browser_name => "iPhone", :platform => :mac, :javascript_enabled => true }.merge(opts)) end |
.json_create(data) ⇒ 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.
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 159 def json_create(data) data = data.dup caps = new caps.browser_name = data.delete("browserName") caps.version = data.delete("version") caps.platform = data.delete("platform").downcase.to_sym if data.has_key?('platform') caps.javascript_enabled = data.delete("javascriptEnabled") caps.css_selectors_enabled = data.delete("cssSelectorsEnabled") caps.takes_screenshot = data.delete("takesScreenshot") caps.native_events = data.delete("nativeEvents") caps.rotatable = data.delete("rotatable") caps.proxy = Proxy.json_create(data['proxy']) if data.has_key?('proxy') # any remaining pairs will be added as is, with no conversion caps.merge!(data) caps end |
.phantomjs(opts = {}) ⇒ 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.
137 138 139 140 141 142 143 144 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 137 def phantomjs(opts = {}) new({ :browser_name => "phantomjs", :javascript_enabled => true, :takes_screenshot => true, :css_selectors_enabled => true }.merge(opts)) end |
.safari(opts = {}) ⇒ 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.
146 147 148 149 150 151 152 153 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 146 def safari(opts = {}) new({ :browser_name => "safari", :javascript_enabled => true, :takes_screenshot => true, :css_selectors_enabled => true }.merge(opts)) end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
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.
264 265 266 267 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 264 def ==(other) return false unless other.kind_of? self.class as_json == other.as_json end |
#[](key) ⇒ 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.
209 210 211 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 209 def [](key) @capabilities[key] end |
#[]=(key, value) ⇒ 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.
Allows setting arbitrary capabilities.
205 206 207 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 205 def []=(key, value) @capabilities[key] = value end |
#as_json(opts = nil) ⇒ 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.
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 237 def as_json(opts = nil) hash = {} @capabilities.each do |key, value| case key when :platform hash['platform'] = value.to_s.upcase when :firefox_profile hash['firefox_profile'] = value.as_json['zip'] if value when :proxy hash['proxy'] = value.as_json if value when String, :firefox_binary hash[key.to_s] = value when Symbol hash[camel_case(key.to_s)] = value else raise TypeError, "expected String or Symbol, got #{key.inspect}:#{key.class} / #{value.inspect}" end end hash end |
#merge!(other) ⇒ 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.
213 214 215 216 217 218 219 220 221 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 213 def merge!(other) if other.respond_to?(:capabilities, true) && other.capabilities.kind_of?(Hash) @capabilities.merge! other.capabilities elsif other.kind_of? Hash @capabilities.merge! other else raise ArgumentError, "argument should be a Hash or implement #capabilities" end end |
#proxy=(proxy) ⇒ 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.
223 224 225 226 227 228 229 230 231 232 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 223 def proxy=(proxy) case proxy when Hash @capabilities[:proxy] = Proxy.new(proxy) when Proxy, nil @capabilities[:proxy] = proxy else raise TypeError, "expected Hash or #{Proxy.name}, got #{proxy.inspect}:#{proxy.class}" end end |
#to_json(*args) ⇒ 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.
260 261 262 |
# File 'lib/selenium/webdriver/remote/capabilities.rb', line 260 def to_json(*args) WebDriver.json_dump as_json end |