selenium-webdriver 2.53.3 → 3.142.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES +665 -8
- data/Gemfile +2 -0
- data/LICENSE +1 -1
- data/README.md +2 -3
- data/lib/selenium/server.rb +76 -73
- data/lib/selenium/webdriver/atoms/getAttribute.js +7 -0
- data/lib/selenium/webdriver/atoms/isDisplayed.js +102 -0
- data/lib/selenium/webdriver/{phantomjs.rb → atoms.rb} +10 -14
- data/lib/selenium/webdriver/chrome/bridge.rb +30 -101
- data/lib/selenium/webdriver/chrome/driver.rb +127 -0
- data/lib/selenium/webdriver/chrome/options.rb +190 -0
- data/lib/selenium/webdriver/chrome/profile.rb +21 -20
- data/lib/selenium/webdriver/chrome/service.rb +26 -93
- data/lib/selenium/webdriver/chrome.rb +15 -6
- data/lib/selenium/webdriver/common/action_builder.rb +52 -58
- data/lib/selenium/webdriver/common/alert.rb +7 -15
- data/lib/selenium/webdriver/common/bridge_helper.rb +18 -22
- data/lib/selenium/webdriver/common/driver.rb +72 -72
- data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +45 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +50 -0
- data/lib/selenium/webdriver/common/driver_extensions/{has_input_devices.rb → has_debugger.rb} +11 -27
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +6 -10
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +7 -8
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +2 -4
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +2 -4
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +3 -5
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +2 -5
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +6 -9
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +9 -7
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +3 -8
- data/lib/selenium/webdriver/common/element.rb +59 -39
- data/lib/selenium/webdriver/common/error.rb +259 -104
- data/lib/selenium/webdriver/common/file_reaper.rb +6 -14
- data/lib/selenium/webdriver/common/html5/local_storage.rb +8 -10
- data/lib/selenium/webdriver/common/html5/session_storage.rb +8 -10
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +8 -16
- data/lib/selenium/webdriver/common/interactions/input_device.rb +54 -0
- data/lib/selenium/webdriver/common/interactions/interaction.rb +53 -0
- data/lib/selenium/webdriver/{safari/browser.rb → common/interactions/interactions.rb} +17 -14
- data/lib/selenium/webdriver/common/interactions/key_actions.rb +145 -0
- data/lib/selenium/webdriver/common/interactions/key_input.rb +66 -0
- data/lib/selenium/webdriver/{android.rb → common/interactions/none_input.rb} +14 -6
- data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +363 -0
- data/lib/selenium/webdriver/common/interactions/pointer_input.rb +139 -0
- data/lib/selenium/webdriver/common/keyboard.rb +10 -14
- data/lib/selenium/webdriver/common/keys.rb +102 -82
- data/lib/selenium/webdriver/common/log_entry.rb +7 -8
- data/lib/selenium/webdriver/common/logger.rb +115 -0
- data/lib/selenium/webdriver/common/logs.rb +4 -6
- data/lib/selenium/webdriver/common/manager.rb +177 -0
- data/lib/selenium/webdriver/common/mouse.rb +12 -14
- data/lib/selenium/webdriver/common/navigation.rb +4 -6
- data/lib/selenium/webdriver/common/options.rb +26 -127
- data/lib/selenium/webdriver/common/platform.rb +75 -101
- data/lib/selenium/webdriver/common/port_prober.rb +7 -19
- data/lib/selenium/webdriver/common/profile_helper.rb +8 -11
- data/lib/selenium/webdriver/common/proxy.rb +68 -74
- data/lib/selenium/webdriver/common/search_context.rb +28 -37
- data/lib/selenium/webdriver/common/service.rb +219 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +15 -16
- data/lib/selenium/webdriver/common/socket_poller.rb +30 -28
- data/lib/selenium/webdriver/common/target_locator.rb +16 -18
- data/lib/selenium/webdriver/common/timeouts.rb +6 -8
- data/lib/selenium/webdriver/common/touch_action_builder.rb +5 -10
- data/lib/selenium/webdriver/common/touch_screen.rb +22 -23
- data/lib/selenium/webdriver/common/w3c_action_builder.rb +212 -0
- data/lib/selenium/webdriver/common/w3c_manager.rb +45 -0
- data/lib/selenium/webdriver/common/wait.rb +17 -16
- data/lib/selenium/webdriver/common/window.rb +50 -17
- data/lib/selenium/webdriver/common/zipper.rb +9 -13
- data/lib/selenium/webdriver/common.rb +21 -7
- data/lib/selenium/webdriver/edge/bridge.rb +34 -63
- data/lib/selenium/webdriver/edge/driver.rb +66 -0
- data/lib/selenium/webdriver/edge/options.rb +80 -0
- data/lib/selenium/webdriver/edge/service.rb +23 -95
- data/lib/selenium/webdriver/edge.rb +13 -13
- data/lib/selenium/webdriver/firefox/binary.rb +45 -60
- data/lib/selenium/webdriver/firefox/driver.rb +50 -0
- data/lib/selenium/webdriver/firefox/extension/prefs.json +3 -12
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/extension.rb +20 -10
- data/lib/selenium/webdriver/firefox/launcher.rb +16 -22
- data/lib/selenium/webdriver/firefox/legacy/driver.rb +83 -0
- data/lib/selenium/webdriver/firefox/marionette/bridge.rb +49 -0
- data/lib/selenium/webdriver/firefox/marionette/driver.rb +90 -0
- data/lib/selenium/webdriver/firefox/options.rb +162 -0
- data/lib/selenium/webdriver/firefox/profile.rb +47 -48
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +11 -18
- data/lib/selenium/webdriver/firefox/service.rb +24 -95
- data/lib/selenium/webdriver/firefox/util.rb +2 -4
- data/lib/selenium/webdriver/firefox.rb +27 -12
- data/lib/selenium/webdriver/ie/driver.rb +85 -0
- data/lib/selenium/webdriver/ie/options.rb +138 -0
- data/lib/selenium/webdriver/ie/service.rb +54 -0
- data/lib/selenium/webdriver/ie.rb +12 -10
- data/lib/selenium/webdriver/remote/bridge.rb +100 -564
- data/lib/selenium/webdriver/remote/capabilities.rb +98 -100
- data/lib/selenium/webdriver/remote/driver.rb +51 -0
- data/lib/selenium/webdriver/remote/http/common.rb +34 -22
- data/lib/selenium/webdriver/remote/http/curb.rb +13 -14
- data/lib/selenium/webdriver/remote/http/default.rb +62 -43
- data/lib/selenium/webdriver/remote/http/persistent.rb +12 -9
- data/lib/selenium/webdriver/remote/oss/bridge.rb +594 -0
- data/lib/selenium/webdriver/remote/oss/commands.rb +223 -0
- data/lib/selenium/webdriver/remote/response.rb +48 -28
- data/lib/selenium/webdriver/remote/server_error.rb +3 -5
- data/lib/selenium/webdriver/remote/w3c/bridge.rb +605 -0
- data/lib/selenium/webdriver/remote/w3c/capabilities.rb +310 -0
- data/lib/selenium/webdriver/remote/w3c/commands.rb +157 -0
- data/lib/selenium/webdriver/remote.rb +10 -16
- data/lib/selenium/webdriver/safari/bridge.rb +17 -101
- data/lib/selenium/webdriver/{firefox/w3c_bridge.rb → safari/driver.rb} +27 -25
- data/lib/selenium/webdriver/safari/options.rb +29 -31
- data/lib/selenium/webdriver/safari/service.rb +38 -0
- data/lib/selenium/webdriver/safari.rb +27 -27
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +19 -4
- data/lib/selenium/webdriver/support/block_event_listener.rb +3 -5
- data/lib/selenium/webdriver/support/color.rb +60 -43
- data/lib/selenium/webdriver/support/escaper.rb +43 -0
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +39 -41
- data/lib/selenium/webdriver/support/select.rb +45 -97
- data/lib/selenium/webdriver/support.rb +3 -2
- data/lib/selenium/webdriver/{iphone.rb → version.rb} +3 -7
- data/lib/selenium/webdriver.rb +36 -23
- data/lib/selenium-webdriver.rb +2 -2
- data/selenium-webdriver.gemspec +42 -29
- metadata +331 -262
- data/lib/selenium/client/base.rb +0 -151
- data/lib/selenium/client/driver.rb +0 -29
- data/lib/selenium/client/errors.rb +0 -28
- data/lib/selenium/client/extensions.rb +0 -132
- data/lib/selenium/client/idiomatic.rb +0 -507
- data/lib/selenium/client/javascript_expression_builder.rb +0 -135
- data/lib/selenium/client/javascript_frameworks/jquery.rb +0 -32
- data/lib/selenium/client/javascript_frameworks/prototype.rb +0 -32
- data/lib/selenium/client/legacy_driver.rb +0 -1722
- data/lib/selenium/client/protocol.rb +0 -123
- data/lib/selenium/client/selenium_helper.rb +0 -49
- data/lib/selenium/client.rb +0 -57
- data/lib/selenium/rake/server_task.rb +0 -176
- data/lib/selenium/webdriver/android/bridge.rb +0 -68
- data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -28
- data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -61
- data/lib/selenium/webdriver/common/html5/location.rb +0 -19
- data/lib/selenium/webdriver/common/w3c_error.rb +0 -194
- data/lib/selenium/webdriver/edge/legacy_support.rb +0 -117
- data/lib/selenium/webdriver/firefox/bridge.rb +0 -89
- data/lib/selenium/webdriver/ie/bridge.rb +0 -88
- data/lib/selenium/webdriver/ie/server.rb +0 -133
- data/lib/selenium/webdriver/iphone/bridge.rb +0 -64
- data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -78
- data/lib/selenium/webdriver/phantomjs/service.rb +0 -130
- data/lib/selenium/webdriver/remote/commands.rb +0 -211
- data/lib/selenium/webdriver/remote/w3c_bridge.rb +0 -668
- data/lib/selenium/webdriver/remote/w3c_capabilities.rb +0 -236
- data/lib/selenium/webdriver/remote/w3c_commands.rb +0 -132
- data/lib/selenium/webdriver/safari/resources/client.js +0 -7255
- data/lib/selenium/webdriver/safari/server.rb +0 -187
- data/lib/selenium-client.rb +0 -21
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
5
5
|
# distributed with this work for additional information
|
@@ -25,132 +25,128 @@ module Selenium
|
|
25
25
|
# server is being asked to create.
|
26
26
|
#
|
27
27
|
class Capabilities
|
28
|
-
|
29
28
|
DEFAULTS = {
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
39
|
-
:
|
40
|
-
}
|
29
|
+
browser_name: '',
|
30
|
+
version: '',
|
31
|
+
platform: :any,
|
32
|
+
javascript_enabled: false,
|
33
|
+
css_selectors_enabled: false,
|
34
|
+
takes_screenshot: false,
|
35
|
+
native_events: false,
|
36
|
+
rotatable: false,
|
37
|
+
firefox_profile: nil,
|
38
|
+
proxy: nil
|
39
|
+
}.freeze
|
41
40
|
|
42
41
|
DEFAULTS.each_key do |key|
|
43
|
-
|
44
|
-
|
42
|
+
if key != :javascript_enabled
|
43
|
+
define_method key do
|
44
|
+
@capabilities.fetch(key)
|
45
|
+
end
|
45
46
|
end
|
46
47
|
|
48
|
+
next if key == :proxy
|
49
|
+
|
47
50
|
define_method "#{key}=" do |value|
|
48
51
|
@capabilities[key] = value
|
49
52
|
end
|
50
53
|
end
|
51
54
|
|
55
|
+
#
|
56
|
+
# Returns javascript_enabled capability.
|
57
|
+
# It is true if not set explicitly.
|
58
|
+
#
|
59
|
+
def javascript_enabled
|
60
|
+
javascript_enabled = @capabilities.fetch(:javascript_enabled)
|
61
|
+
javascript_enabled.nil? ? true : javascript_enabled
|
62
|
+
end
|
63
|
+
|
52
64
|
alias_method :css_selectors_enabled?, :css_selectors_enabled
|
53
|
-
alias_method :javascript_enabled
|
54
|
-
alias_method :native_events
|
55
|
-
alias_method :takes_screenshot
|
56
|
-
alias_method :rotatable
|
65
|
+
alias_method :javascript_enabled?, :javascript_enabled
|
66
|
+
alias_method :native_events?, :native_events
|
67
|
+
alias_method :takes_screenshot?, :takes_screenshot
|
68
|
+
alias_method :rotatable?, :rotatable
|
57
69
|
|
58
70
|
#
|
59
71
|
# Convenience methods for the common choices.
|
60
72
|
#
|
61
73
|
|
62
74
|
class << self
|
63
|
-
def android(opts = {})
|
64
|
-
new({
|
65
|
-
:browser_name => "android",
|
66
|
-
:platform => :android,
|
67
|
-
:javascript_enabled => true,
|
68
|
-
:rotatable => true,
|
69
|
-
:takes_screenshot => true
|
70
|
-
}.merge(opts))
|
71
|
-
end
|
72
|
-
|
73
75
|
def chrome(opts = {})
|
74
76
|
new({
|
75
|
-
:
|
76
|
-
:
|
77
|
-
:
|
78
|
-
|
79
|
-
:driver => "ALL"}
|
80
|
-
}.merge(opts))
|
77
|
+
browser_name: 'chrome',
|
78
|
+
javascript_enabled: true,
|
79
|
+
css_selectors_enabled: true
|
80
|
+
}.merge(opts))
|
81
81
|
end
|
82
82
|
|
83
83
|
def edge(opts = {})
|
84
|
-
|
84
|
+
new({
|
85
|
+
browser_name: 'MicrosoftEdge',
|
86
|
+
platform: :windows
|
87
|
+
}.merge(opts))
|
85
88
|
end
|
86
89
|
|
87
90
|
def firefox(opts = {})
|
88
|
-
|
91
|
+
opts[:browser_version] = opts.delete(:version) if opts.key?(:version)
|
92
|
+
opts[:platform_name] = opts.delete(:platform) if opts.key?(:platform)
|
93
|
+
opts[:timeouts] = {}
|
94
|
+
opts[:timeouts]['implicit'] = opts.delete(:implicit_timeout) if opts.key?(:implicit_timeout)
|
95
|
+
opts[:timeouts]['pageLoad'] = opts.delete(:page_load_timeout) if opts.key?(:page_load_timeout)
|
96
|
+
opts[:timeouts]['script'] = opts.delete(:script_timeout) if opts.key?(:script_timeout)
|
97
|
+
new({browser_name: 'firefox', marionette: true}.merge(opts))
|
98
|
+
end
|
89
99
|
|
100
|
+
def firefox_legacy(opts = {})
|
90
101
|
new({
|
91
|
-
:
|
92
|
-
:
|
93
|
-
:
|
94
|
-
:
|
102
|
+
browser_name: 'firefox',
|
103
|
+
javascript_enabled: true,
|
104
|
+
takes_screenshot: true,
|
105
|
+
css_selectors_enabled: true
|
95
106
|
}.merge(opts))
|
96
107
|
end
|
97
108
|
|
98
109
|
def htmlunit(opts = {})
|
99
110
|
new({
|
100
|
-
:
|
111
|
+
browser_name: 'htmlunit'
|
101
112
|
}.merge(opts))
|
102
113
|
end
|
103
114
|
|
104
115
|
def htmlunitwithjs(opts = {})
|
105
116
|
new({
|
106
|
-
:
|
107
|
-
:
|
117
|
+
browser_name: 'htmlunit',
|
118
|
+
javascript_enabled: true
|
108
119
|
}.merge(opts))
|
109
120
|
end
|
110
121
|
|
111
122
|
def internet_explorer(opts = {})
|
112
123
|
new({
|
113
|
-
:
|
114
|
-
:
|
115
|
-
:
|
116
|
-
:
|
117
|
-
:
|
124
|
+
browser_name: 'internet explorer',
|
125
|
+
platform: :windows,
|
126
|
+
takes_screenshot: true,
|
127
|
+
css_selectors_enabled: true,
|
128
|
+
native_events: true
|
118
129
|
}.merge(opts))
|
119
130
|
end
|
120
131
|
alias_method :ie, :internet_explorer
|
121
132
|
|
122
|
-
def iphone(opts = {})
|
123
|
-
new({
|
124
|
-
:browser_name => "iPhone",
|
125
|
-
:platform => :mac,
|
126
|
-
:javascript_enabled => true
|
127
|
-
}.merge(opts))
|
128
|
-
end
|
129
|
-
|
130
|
-
def ipad(opts = {})
|
131
|
-
new({
|
132
|
-
:browser_name => "iPad",
|
133
|
-
:platform => :mac,
|
134
|
-
:javascript_enabled => true
|
135
|
-
}.merge(opts))
|
136
|
-
end
|
137
|
-
|
138
133
|
def phantomjs(opts = {})
|
134
|
+
WebDriver.logger.deprecate 'Selenium support for PhantomJS', 'headless Chrome/Firefox or HTMLUnit'
|
139
135
|
new({
|
140
|
-
:
|
141
|
-
:
|
142
|
-
:
|
143
|
-
:
|
136
|
+
browser_name: 'phantomjs',
|
137
|
+
javascript_enabled: true,
|
138
|
+
takes_screenshot: true,
|
139
|
+
css_selectors_enabled: true
|
144
140
|
}.merge(opts))
|
145
141
|
end
|
146
142
|
|
147
143
|
def safari(opts = {})
|
148
144
|
new({
|
149
|
-
:
|
150
|
-
:
|
151
|
-
:
|
152
|
-
:
|
153
|
-
:
|
145
|
+
browser_name: 'safari',
|
146
|
+
platform: :mac,
|
147
|
+
javascript_enabled: true,
|
148
|
+
takes_screenshot: true,
|
149
|
+
css_selectors_enabled: true
|
154
150
|
}.merge(opts))
|
155
151
|
end
|
156
152
|
|
@@ -162,15 +158,15 @@ module Selenium
|
|
162
158
|
data = data.dup
|
163
159
|
|
164
160
|
caps = new
|
165
|
-
caps.browser_name = data.delete(
|
166
|
-
caps.version = data.delete(
|
167
|
-
caps.platform = data.delete(
|
168
|
-
caps.javascript_enabled = data.delete(
|
169
|
-
caps.css_selectors_enabled = data.delete(
|
170
|
-
caps.takes_screenshot = data.delete(
|
171
|
-
caps.native_events = data.delete(
|
172
|
-
caps.rotatable = data.delete(
|
173
|
-
caps.proxy = Proxy.json_create(data['proxy']) if data.
|
161
|
+
caps.browser_name = data.delete('browserName')
|
162
|
+
caps.version = data.delete('version')
|
163
|
+
caps.platform = data.delete('platform').downcase.tr(' ', '_').to_sym if data.key?('platform')
|
164
|
+
caps.javascript_enabled = data.delete('javascriptEnabled')
|
165
|
+
caps.css_selectors_enabled = data.delete('cssSelectorsEnabled')
|
166
|
+
caps.takes_screenshot = data.delete('takesScreenshot')
|
167
|
+
caps.native_events = data.delete('nativeEvents')
|
168
|
+
caps.rotatable = data.delete('rotatable')
|
169
|
+
caps.proxy = Proxy.json_create(data['proxy']) if data.key?('proxy') && !data['proxy'].empty?
|
174
170
|
|
175
171
|
# any remaining pairs will be added as is, with no conversion
|
176
172
|
caps.merge!(data)
|
@@ -179,6 +175,7 @@ module Selenium
|
|
179
175
|
end
|
180
176
|
end
|
181
177
|
|
178
|
+
#
|
182
179
|
# @option :browser_name [String] required browser name
|
183
180
|
# @option :version [String] required browser version number
|
184
181
|
# @option :platform [Symbol] one of :any, :win, :mac, or :x
|
@@ -188,10 +185,6 @@ module Selenium
|
|
188
185
|
# @option :native_events [Boolean] does this driver use native events?
|
189
186
|
# @option :proxy [Selenium::WebDriver::Proxy, Hash] proxy configuration
|
190
187
|
#
|
191
|
-
# Firefox-specific options:
|
192
|
-
#
|
193
|
-
# @option :firefox_profile [Selenium::WebDriver::Firefox::Profile] the firefox profile to use
|
194
|
-
#
|
195
188
|
# @api public
|
196
189
|
#
|
197
190
|
|
@@ -213,12 +206,12 @@ module Selenium
|
|
213
206
|
end
|
214
207
|
|
215
208
|
def merge!(other)
|
216
|
-
if other.respond_to?(:capabilities, true) && other.capabilities.
|
209
|
+
if other.respond_to?(:capabilities, true) && other.capabilities.is_a?(Hash)
|
217
210
|
@capabilities.merge! other.capabilities
|
218
|
-
elsif other.
|
211
|
+
elsif other.is_a? Hash
|
219
212
|
@capabilities.merge! other
|
220
213
|
else
|
221
|
-
raise ArgumentError,
|
214
|
+
raise ArgumentError, 'argument should be a Hash or implement #capabilities'
|
222
215
|
end
|
223
216
|
end
|
224
217
|
|
@@ -233,10 +226,11 @@ module Selenium
|
|
233
226
|
end
|
234
227
|
end
|
235
228
|
|
229
|
+
#
|
236
230
|
# @api private
|
237
231
|
#
|
238
232
|
|
239
|
-
def as_json(
|
233
|
+
def as_json(*) # rubocop:disable Metrics/CyclomaticComplexity
|
240
234
|
hash = {}
|
241
235
|
|
242
236
|
@capabilities.each do |key, value|
|
@@ -244,10 +238,16 @@ module Selenium
|
|
244
238
|
when :platform
|
245
239
|
hash['platform'] = value.to_s.upcase
|
246
240
|
when :firefox_profile
|
247
|
-
|
241
|
+
if value
|
242
|
+
WebDriver.logger.deprecate(':firefox_profile capabilitiy', 'Selenium::WebDriver::Firefox::Options#profile')
|
243
|
+
hash['firefox_profile'] = value.as_json['zip']
|
244
|
+
end
|
248
245
|
when :proxy
|
249
246
|
hash['proxy'] = value.as_json if value
|
250
247
|
when String, :firefox_binary
|
248
|
+
if key == :firefox_binary && value
|
249
|
+
WebDriver.logger.deprecate(':firefox_binary capabilitiy', 'Selenium::WebDriver::Firefox::Options#binary')
|
250
|
+
end
|
251
251
|
hash[key.to_s] = value
|
252
252
|
when Symbol
|
253
253
|
hash[camel_case(key.to_s)] = value
|
@@ -259,28 +259,26 @@ module Selenium
|
|
259
259
|
hash
|
260
260
|
end
|
261
261
|
|
262
|
-
def to_json(*
|
262
|
+
def to_json(*)
|
263
263
|
JSON.generate as_json
|
264
264
|
end
|
265
265
|
|
266
266
|
def ==(other)
|
267
|
-
return false unless other.
|
267
|
+
return false unless other.is_a? self.class
|
268
|
+
|
268
269
|
as_json == other.as_json
|
269
270
|
end
|
270
271
|
alias_method :eql?, :==
|
271
272
|
|
272
273
|
protected
|
273
274
|
|
274
|
-
|
275
|
-
@capabilities
|
276
|
-
end
|
275
|
+
attr_reader :capabilities
|
277
276
|
|
278
277
|
private
|
279
278
|
|
280
279
|
def camel_case(str)
|
281
|
-
str.gsub(/_([a-z])/) {
|
280
|
+
str.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
|
282
281
|
end
|
283
|
-
|
284
282
|
end # Capabilities
|
285
283
|
end # Remote
|
286
284
|
end # WebDriver
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
module Remote
|
23
|
+
|
24
|
+
#
|
25
|
+
# Driver implementation for remote server.
|
26
|
+
# @api private
|
27
|
+
#
|
28
|
+
|
29
|
+
class Driver < WebDriver::Driver
|
30
|
+
include DriverExtensions::UploadsFiles
|
31
|
+
include DriverExtensions::TakesScreenshot
|
32
|
+
include DriverExtensions::HasSessionId
|
33
|
+
include DriverExtensions::Rotatable
|
34
|
+
include DriverExtensions::HasRemoteStatus
|
35
|
+
include DriverExtensions::HasWebStorage
|
36
|
+
|
37
|
+
def initialize(opts = {})
|
38
|
+
listener = opts.delete(:listener)
|
39
|
+
@bridge = Bridge.handshake(opts)
|
40
|
+
if @bridge.dialect == :oss
|
41
|
+
extend DriverExtensions::HasTouchScreen
|
42
|
+
extend DriverExtensions::HasLocation
|
43
|
+
extend DriverExtensions::HasNetworkConnection
|
44
|
+
end
|
45
|
+
super(@bridge, listener: listener)
|
46
|
+
end
|
47
|
+
|
48
|
+
end # Driver
|
49
|
+
end # Remote
|
50
|
+
end # WebDriver
|
51
|
+
end # Selenium
|
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
5
5
|
# distributed with this work for additional information
|
@@ -23,8 +23,12 @@ module Selenium
|
|
23
23
|
module Http
|
24
24
|
class Common
|
25
25
|
MAX_REDIRECTS = 20 # same as chromium/gecko
|
26
|
-
CONTENT_TYPE =
|
27
|
-
DEFAULT_HEADERS = {
|
26
|
+
CONTENT_TYPE = 'application/json'
|
27
|
+
DEFAULT_HEADERS = {
|
28
|
+
'Accept' => CONTENT_TYPE,
|
29
|
+
'Content-Type' => "#{CONTENT_TYPE}; charset=UTF-8",
|
30
|
+
'User-Agent' => "selenium/#{WebDriver::VERSION} (ruby #{Platform.os})"
|
31
|
+
}.freeze
|
28
32
|
|
29
33
|
attr_accessor :timeout
|
30
34
|
attr_writer :server_url
|
@@ -33,27 +37,28 @@ module Selenium
|
|
33
37
|
@timeout = nil
|
34
38
|
end
|
35
39
|
|
40
|
+
def quit_errors
|
41
|
+
[IOError]
|
42
|
+
end
|
43
|
+
|
36
44
|
def close
|
37
45
|
# hook for subclasses - will be called on Driver#quit
|
38
46
|
end
|
39
47
|
|
40
48
|
def call(verb, url, command_hash)
|
41
|
-
url = server_url.merge(url) unless url.
|
49
|
+
url = server_url.merge(url) unless url.is_a?(URI)
|
42
50
|
headers = DEFAULT_HEADERS.dup
|
43
|
-
headers['Cache-Control'] =
|
51
|
+
headers['Cache-Control'] = 'no-cache' if verb == :get
|
44
52
|
|
45
53
|
if command_hash
|
46
54
|
payload = JSON.generate(command_hash)
|
47
|
-
headers[
|
48
|
-
headers["Content-Length"] = payload.bytesize.to_s if [:post, :put].include?(verb)
|
55
|
+
headers['Content-Length'] = payload.bytesize.to_s if %i[post put].include?(verb)
|
49
56
|
|
50
|
-
|
51
|
-
|
52
|
-
puts " > #{headers.inspect}"
|
53
|
-
end
|
57
|
+
WebDriver.logger.info(" >>> #{url} | #{payload}")
|
58
|
+
WebDriver.logger.debug(" > #{headers.inspect}")
|
54
59
|
elsif verb == :post
|
55
|
-
payload =
|
56
|
-
headers[
|
60
|
+
payload = '{}'
|
61
|
+
headers['Content-Length'] = '2'
|
57
62
|
end
|
58
63
|
|
59
64
|
request verb, url, headers, payload
|
@@ -62,30 +67,37 @@ module Selenium
|
|
62
67
|
private
|
63
68
|
|
64
69
|
def server_url
|
65
|
-
@server_url
|
70
|
+
return @server_url if @server_url
|
71
|
+
|
72
|
+
raise Error::WebDriverError, 'server_url not set'
|
66
73
|
end
|
67
74
|
|
68
|
-
def request(
|
69
|
-
raise NotImplementedError,
|
75
|
+
def request(*)
|
76
|
+
raise NotImplementedError, 'subclass responsibility'
|
70
77
|
end
|
71
78
|
|
72
79
|
def create_response(code, body, content_type)
|
73
|
-
code
|
74
|
-
|
80
|
+
code = code.to_i
|
81
|
+
body = body.to_s.strip
|
82
|
+
content_type = content_type.to_s
|
83
|
+
WebDriver.logger.info("<- #{body}")
|
75
84
|
|
76
85
|
if content_type.include? CONTENT_TYPE
|
77
86
|
raise Error::WebDriverError, "empty body: #{content_type.inspect} (#{code})\n#{body}" if body.empty?
|
87
|
+
|
78
88
|
Response.new(code, JSON.parse(body))
|
79
89
|
elsif code == 204
|
80
90
|
Response.new(code)
|
81
91
|
else
|
82
|
-
msg =
|
83
|
-
|
92
|
+
msg = if body.empty?
|
93
|
+
"unexpected response, code=#{code}, content-type=#{content_type.inspect}"
|
94
|
+
else
|
95
|
+
"unexpected response, code=#{code}, content-type=#{content_type.inspect}\n#{body}"
|
96
|
+
end
|
84
97
|
|
85
98
|
raise Error::WebDriverError, msg
|
86
99
|
end
|
87
100
|
end
|
88
|
-
|
89
101
|
end # Common
|
90
102
|
end # Http
|
91
103
|
end # Remote
|
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
5
5
|
# distributed with this work for additional information
|
@@ -23,11 +23,7 @@ module Selenium
|
|
23
23
|
module WebDriver
|
24
24
|
module Remote
|
25
25
|
|
26
|
-
# added for rescue
|
27
|
-
Bridge::QUIT_ERRORS << Curl::Err::RecvError
|
28
|
-
|
29
26
|
module Http
|
30
|
-
|
31
27
|
#
|
32
28
|
# An alternative to the default Net::HTTP client.
|
33
29
|
#
|
@@ -43,14 +39,18 @@ module Selenium
|
|
43
39
|
|
44
40
|
class Curb < Common
|
45
41
|
|
42
|
+
def quit_errors
|
43
|
+
[Curl::Err::RecvError] + super
|
44
|
+
end
|
45
|
+
|
46
46
|
private
|
47
47
|
|
48
48
|
def request(verb, url, headers, payload)
|
49
|
-
client.url
|
49
|
+
client.url = url.to_s
|
50
50
|
|
51
51
|
# workaround for http://github.com/taf2/curb/issues/issue/40
|
52
52
|
# curb will handle this for us anyway
|
53
|
-
headers.delete
|
53
|
+
headers.delete 'Content-Length'
|
54
54
|
|
55
55
|
client.headers = headers
|
56
56
|
|
@@ -62,10 +62,10 @@ module Selenium
|
|
62
62
|
when :get
|
63
63
|
client.http_get
|
64
64
|
when :post
|
65
|
-
client.post_body = payload ||
|
65
|
+
client.post_body = payload || ''
|
66
66
|
client.http_post
|
67
67
|
when :put
|
68
|
-
client.put_data = payload ||
|
68
|
+
client.put_data = payload || ''
|
69
69
|
client.http_put
|
70
70
|
when :delete
|
71
71
|
client.http_delete
|
@@ -79,18 +79,17 @@ module Selenium
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def client
|
82
|
-
@client ||=
|
82
|
+
@client ||= begin
|
83
83
|
c = Curl::Easy.new
|
84
84
|
|
85
85
|
c.max_redirects = MAX_REDIRECTS
|
86
86
|
c.follow_location = true
|
87
87
|
c.timeout = @timeout if @timeout
|
88
|
-
c.verbose =
|
88
|
+
c.verbose = WebDriver.logger.info?
|
89
89
|
|
90
90
|
c
|
91
|
-
|
91
|
+
end
|
92
92
|
end
|
93
|
-
|
94
93
|
end # Curb
|
95
94
|
end # Http
|
96
95
|
end # Remote
|