selenium-webdriver 2.45.0 → 3.142.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGES +795 -3
- data/Gemfile +2 -0
- data/{COPYING → LICENSE} +1 -3
- data/README.md +13 -9
- data/lib/selenium/server.rb +93 -71
- data/lib/selenium/webdriver/atoms/getAttribute.js +7 -0
- data/lib/selenium/webdriver/atoms/isDisplayed.js +102 -0
- data/lib/selenium/webdriver/atoms.rb +37 -0
- data/lib/selenium/webdriver/chrome/bridge.rb +47 -99
- 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 +40 -20
- data/lib/selenium/webdriver/chrome/service.rb +46 -62
- data/lib/selenium/webdriver/chrome.rb +34 -6
- data/lib/selenium/webdriver/common/action_builder.rb +69 -56
- data/lib/selenium/webdriver/common/alert.rb +25 -8
- data/lib/selenium/webdriver/common/bridge_helper.rb +35 -20
- data/lib/selenium/webdriver/common/driver.rb +90 -63
- 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_debugger.rb +42 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +26 -11
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +58 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +23 -6
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +19 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +24 -7
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +19 -3
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +23 -7
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +26 -5
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +20 -6
- data/lib/selenium/webdriver/common/element.rb +79 -37
- data/lib/selenium/webdriver/common/error.rb +282 -106
- data/lib/selenium/webdriver/common/file_reaper.rb +23 -12
- data/lib/selenium/webdriver/common/html5/local_storage.rb +29 -12
- data/lib/selenium/webdriver/common/html5/session_storage.rb +29 -12
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +29 -18
- 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/common/interactions/interactions.rb +43 -0
- 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/common/interactions/none_input.rb +36 -0
- 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 +27 -12
- data/lib/selenium/webdriver/common/keys.rb +118 -81
- data/lib/selenium/webdriver/common/log_entry.rb +27 -8
- data/lib/selenium/webdriver/common/logger.rb +115 -0
- data/lib/selenium/webdriver/common/logs.rb +24 -7
- data/lib/selenium/webdriver/common/manager.rb +177 -0
- data/lib/selenium/webdriver/common/mouse.rb +29 -12
- data/lib/selenium/webdriver/common/navigation.rb +21 -4
- data/lib/selenium/webdriver/common/options.rb +43 -126
- data/lib/selenium/webdriver/common/platform.rb +101 -97
- data/lib/selenium/webdriver/common/port_prober.rb +24 -17
- data/lib/selenium/webdriver/common/profile_helper.rb +27 -11
- data/lib/selenium/webdriver/common/proxy.rb +86 -73
- data/lib/selenium/webdriver/common/search_context.rb +49 -33
- data/lib/selenium/webdriver/common/service.rb +219 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +82 -0
- data/lib/selenium/webdriver/common/socket_poller.rb +47 -26
- data/lib/selenium/webdriver/common/target_locator.rb +35 -14
- data/lib/selenium/webdriver/common/timeouts.rb +23 -6
- data/lib/selenium/webdriver/common/touch_action_builder.rb +25 -11
- data/lib/selenium/webdriver/common/touch_screen.rb +42 -24
- 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 +34 -14
- data/lib/selenium/webdriver/common/window.rb +75 -16
- data/lib/selenium/webdriver/common/zipper.rb +26 -11
- data/lib/selenium/webdriver/common.rb +40 -7
- data/lib/selenium/webdriver/edge/bridge.rb +76 -0
- 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 +52 -0
- data/lib/selenium/webdriver/edge.rb +44 -0
- data/lib/selenium/webdriver/firefox/binary.rb +70 -48
- data/lib/selenium/webdriver/firefox/driver.rb +50 -0
- data/lib/selenium/webdriver/firefox/extension/prefs.json +14 -13
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/extension.rb +50 -19
- data/lib/selenium/webdriver/firefox/launcher.rb +33 -28
- 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 +66 -48
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +28 -16
- data/lib/selenium/webdriver/firefox/service.rb +52 -0
- data/lib/selenium/webdriver/firefox/util.rb +19 -2
- data/lib/selenium/webdriver/firefox.rb +46 -10
- 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 +32 -10
- data/lib/selenium/webdriver/remote/bridge.rb +117 -572
- data/lib/selenium/webdriver/remote/capabilities.rb +116 -99
- data/lib/selenium/webdriver/remote/driver.rb +51 -0
- data/lib/selenium/webdriver/remote/http/common.rb +54 -23
- data/lib/selenium/webdriver/remote/http/curb.rb +30 -12
- data/lib/selenium/webdriver/remote/http/default.rb +85 -42
- data/lib/selenium/webdriver/remote/http/persistent.rb +29 -7
- 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 +68 -30
- data/lib/selenium/webdriver/remote/server_error.rb +22 -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 +27 -13
- data/lib/selenium/webdriver/safari/bridge.rb +38 -107
- data/lib/selenium/webdriver/safari/driver.rb +68 -0
- data/lib/selenium/webdriver/safari/options.rb +56 -75
- data/lib/selenium/webdriver/safari/service.rb +38 -0
- data/lib/selenium/webdriver/safari.rb +49 -31
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +40 -6
- data/lib/selenium/webdriver/support/block_event_listener.rb +24 -7
- data/lib/selenium/webdriver/support/color.rb +82 -46
- data/lib/selenium/webdriver/support/escaper.rb +43 -0
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +56 -39
- data/lib/selenium/webdriver/support/select.rb +66 -89
- data/lib/selenium/webdriver/support.rb +20 -0
- data/lib/selenium/webdriver/version.rb +24 -0
- data/lib/selenium/webdriver.rb +55 -25
- data/lib/selenium-webdriver.rb +19 -0
- data/selenium-webdriver.gemspec +42 -29
- metadata +331 -260
- data/Gemfile.lock +0 -48
- data/lib/selenium/client/base.rb +0 -132
- data/lib/selenium/client/driver.rb +0 -10
- data/lib/selenium/client/errors.rb +0 -9
- data/lib/selenium/client/extensions.rb +0 -118
- data/lib/selenium/client/idiomatic.rb +0 -488
- data/lib/selenium/client/javascript_expression_builder.rb +0 -116
- data/lib/selenium/client/javascript_frameworks/jquery.rb +0 -13
- data/lib/selenium/client/javascript_frameworks/prototype.rb +0 -13
- data/lib/selenium/client/legacy_driver.rb +0 -1720
- data/lib/selenium/client/protocol.rb +0 -104
- data/lib/selenium/client/selenium_helper.rb +0 -34
- data/lib/selenium/client.rb +0 -38
- data/lib/selenium/rake/server_task.rb +0 -157
- data/lib/selenium/webdriver/android/bridge.rb +0 -49
- data/lib/selenium/webdriver/android.rb +0 -9
- data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -9
- data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -42
- data/lib/selenium/webdriver/common/core_ext/string.rb +0 -5
- data/lib/selenium/webdriver/common/driver_extensions/has_browser_connection.rb +0 -17
- data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +0 -39
- data/lib/selenium/webdriver/common/html5/location.rb +0 -0
- data/lib/selenium/webdriver/common/json_helper.rb +0 -34
- data/lib/selenium/webdriver/firefox/bridge.rb +0 -70
- data/lib/selenium/webdriver/firefox/socket_lock.rb +0 -61
- data/lib/selenium/webdriver/ie/bridge.rb +0 -69
- data/lib/selenium/webdriver/ie/server.rb +0 -90
- data/lib/selenium/webdriver/iphone/bridge.rb +0 -45
- data/lib/selenium/webdriver/iphone.rb +0 -9
- data/lib/selenium/webdriver/opera/bridge.rb +0 -112
- data/lib/selenium/webdriver/opera/service.rb +0 -49
- data/lib/selenium/webdriver/opera.rb +0 -24
- data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -59
- data/lib/selenium/webdriver/phantomjs/service.rb +0 -90
- data/lib/selenium/webdriver/phantomjs.rb +0 -22
- data/lib/selenium/webdriver/remote/commands.rb +0 -192
- data/lib/selenium/webdriver/safari/browser.rb +0 -20
- data/lib/selenium/webdriver/safari/extensions.rb +0 -170
- data/lib/selenium/webdriver/safari/resources/SafariDriver.safariextz +0 -0
- data/lib/selenium/webdriver/safari/resources/client.js +0 -6903
- data/lib/selenium/webdriver/safari/server.rb +0 -145
- data/lib/selenium-client.rb +0 -2
|
@@ -1,6 +1,24 @@
|
|
|
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
|
+
|
|
1
20
|
module Selenium
|
|
2
21
|
module WebDriver
|
|
3
|
-
|
|
4
22
|
#
|
|
5
23
|
# The main class through which you control the browser.
|
|
6
24
|
#
|
|
@@ -14,7 +32,6 @@ module Selenium
|
|
|
14
32
|
include SearchContext
|
|
15
33
|
|
|
16
34
|
class << self
|
|
17
|
-
|
|
18
35
|
#
|
|
19
36
|
# @api private
|
|
20
37
|
#
|
|
@@ -24,34 +41,24 @@ module Selenium
|
|
|
24
41
|
#
|
|
25
42
|
|
|
26
43
|
def for(browser, opts = {})
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
PhantomJS::Bridge.new(opts)
|
|
46
|
-
when :safari
|
|
47
|
-
Safari::Bridge.new(opts)
|
|
48
|
-
else
|
|
49
|
-
raise ArgumentError, "unknown driver: #{browser.inspect}"
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
bridge = Support::EventFiringBridge.new(bridge, listener) if listener
|
|
53
|
-
|
|
54
|
-
new(bridge)
|
|
44
|
+
case browser
|
|
45
|
+
when :chrome
|
|
46
|
+
Chrome::Driver.new(opts)
|
|
47
|
+
when :internet_explorer, :ie
|
|
48
|
+
IE::Driver.new(opts)
|
|
49
|
+
when :safari
|
|
50
|
+
Safari::Driver.new(opts)
|
|
51
|
+
when :phantomjs
|
|
52
|
+
PhantomJS::Driver.new(opts)
|
|
53
|
+
when :firefox, :ff
|
|
54
|
+
Firefox::Driver.new(opts)
|
|
55
|
+
when :edge
|
|
56
|
+
Edge::Driver.new(opts)
|
|
57
|
+
when :remote
|
|
58
|
+
Remote::Driver.new(opts)
|
|
59
|
+
else
|
|
60
|
+
raise ArgumentError, "unknown driver: #{browser.inspect}"
|
|
61
|
+
end
|
|
55
62
|
end
|
|
56
63
|
end
|
|
57
64
|
|
|
@@ -62,17 +69,13 @@ module Selenium
|
|
|
62
69
|
# @api private
|
|
63
70
|
#
|
|
64
71
|
|
|
65
|
-
def initialize(bridge)
|
|
72
|
+
def initialize(bridge, listener: nil)
|
|
66
73
|
@bridge = bridge
|
|
67
|
-
|
|
68
|
-
# TODO: refactor this away
|
|
69
|
-
unless bridge.driver_extensions.empty?
|
|
70
|
-
extend(*bridge.driver_extensions)
|
|
71
|
-
end
|
|
74
|
+
@bridge = Support::EventFiringBridge.new(bridge, listener) if listener
|
|
72
75
|
end
|
|
73
76
|
|
|
74
77
|
def inspect
|
|
75
|
-
'
|
|
78
|
+
format '#<%<class>s:0x%<hash>x browser=%<browser>s>', class: self.class, hash: hash * 2, browser: bridge.browser.inspect
|
|
76
79
|
end
|
|
77
80
|
|
|
78
81
|
#
|
|
@@ -94,12 +97,29 @@ module Selenium
|
|
|
94
97
|
end
|
|
95
98
|
|
|
96
99
|
#
|
|
97
|
-
# @return [
|
|
98
|
-
# @see
|
|
100
|
+
# @return [Manager]
|
|
101
|
+
# @see Manager
|
|
99
102
|
#
|
|
100
103
|
|
|
101
104
|
def manage
|
|
102
|
-
|
|
105
|
+
bridge.manage
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
#
|
|
109
|
+
# @return [ActionBuilder, W3CActionBuilder]
|
|
110
|
+
# @see ActionBuilder, W3CActionBuilder
|
|
111
|
+
#
|
|
112
|
+
|
|
113
|
+
def action
|
|
114
|
+
bridge.action
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def mouse
|
|
118
|
+
bridge.mouse
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def keyboard
|
|
122
|
+
bridge.keyboard
|
|
103
123
|
end
|
|
104
124
|
|
|
105
125
|
#
|
|
@@ -117,7 +137,7 @@ module Selenium
|
|
|
117
137
|
#
|
|
118
138
|
|
|
119
139
|
def current_url
|
|
120
|
-
bridge.
|
|
140
|
+
bridge.url
|
|
121
141
|
end
|
|
122
142
|
|
|
123
143
|
#
|
|
@@ -127,7 +147,7 @@ module Selenium
|
|
|
127
147
|
#
|
|
128
148
|
|
|
129
149
|
def title
|
|
130
|
-
bridge.
|
|
150
|
+
bridge.title
|
|
131
151
|
end
|
|
132
152
|
|
|
133
153
|
#
|
|
@@ -137,7 +157,7 @@ module Selenium
|
|
|
137
157
|
#
|
|
138
158
|
|
|
139
159
|
def page_source
|
|
140
|
-
bridge.
|
|
160
|
+
bridge.page_source
|
|
141
161
|
end
|
|
142
162
|
|
|
143
163
|
#
|
|
@@ -164,7 +184,7 @@ module Selenium
|
|
|
164
184
|
#
|
|
165
185
|
|
|
166
186
|
def window_handles
|
|
167
|
-
bridge.
|
|
187
|
+
bridge.window_handles
|
|
168
188
|
end
|
|
169
189
|
|
|
170
190
|
#
|
|
@@ -174,7 +194,7 @@ module Selenium
|
|
|
174
194
|
#
|
|
175
195
|
|
|
176
196
|
def window_handle
|
|
177
|
-
bridge.
|
|
197
|
+
bridge.window_handle
|
|
178
198
|
end
|
|
179
199
|
|
|
180
200
|
#
|
|
@@ -182,7 +202,7 @@ module Selenium
|
|
|
182
202
|
#
|
|
183
203
|
# @param [String] script
|
|
184
204
|
# JavaScript source to execute
|
|
185
|
-
# @param [WebDriver::Element,Integer, Float, Boolean, NilClass, String, Array]
|
|
205
|
+
# @param [WebDriver::Element, Integer, Float, Boolean, NilClass, String, Array] args
|
|
186
206
|
# Arguments will be available in the given script in the 'arguments' pseudo-array.
|
|
187
207
|
#
|
|
188
208
|
# @return [WebDriver::Element,Integer,Float,Boolean,NilClass,String,Array]
|
|
@@ -190,7 +210,7 @@ module Selenium
|
|
|
190
210
|
#
|
|
191
211
|
|
|
192
212
|
def execute_script(script, *args)
|
|
193
|
-
bridge.
|
|
213
|
+
bridge.execute_script(script, *args)
|
|
194
214
|
end
|
|
195
215
|
|
|
196
216
|
# Execute an asynchronous piece of JavaScript in the context of the
|
|
@@ -201,28 +221,27 @@ module Selenium
|
|
|
201
221
|
# executed function as the last argument.
|
|
202
222
|
#
|
|
203
223
|
# @param [String] script
|
|
204
|
-
#
|
|
205
|
-
# @param [WebDriver::Element,Integer, Float, Boolean, NilClass, String, Array]
|
|
224
|
+
# JavaScript source to execute
|
|
225
|
+
# @param [WebDriver::Element,Integer, Float, Boolean, NilClass, String, Array] args
|
|
206
226
|
# Arguments to the script. May be empty.
|
|
207
227
|
#
|
|
208
228
|
# @return [WebDriver::Element,Integer,Float,Boolean,NilClass,String,Array]
|
|
209
229
|
#
|
|
210
230
|
|
|
211
231
|
def execute_async_script(script, *args)
|
|
212
|
-
bridge.
|
|
232
|
+
bridge.execute_async_script(script, *args)
|
|
213
233
|
end
|
|
214
234
|
|
|
215
|
-
|
|
216
235
|
#-------------------------------- sugar --------------------------------
|
|
217
236
|
|
|
218
237
|
#
|
|
219
|
-
# driver.first(:
|
|
238
|
+
# driver.first(id: 'foo')
|
|
220
239
|
#
|
|
221
240
|
|
|
222
241
|
alias_method :first, :find_element
|
|
223
242
|
|
|
224
243
|
#
|
|
225
|
-
# driver.all(:
|
|
244
|
+
# driver.all(class: 'bar') #=> [#<WebDriver::Element:0x1011c3b88, ...]
|
|
226
245
|
#
|
|
227
246
|
|
|
228
247
|
alias_method :all, :find_elements
|
|
@@ -236,7 +255,7 @@ module Selenium
|
|
|
236
255
|
# Get the first element matching the given selector. If given a
|
|
237
256
|
# String or Symbol, it will be used as the id of the element.
|
|
238
257
|
#
|
|
239
|
-
# @param [String,Hash] id or selector
|
|
258
|
+
# @param [String,Hash] sel id or selector
|
|
240
259
|
# @return [WebDriver::Element]
|
|
241
260
|
#
|
|
242
261
|
# Examples:
|
|
@@ -246,9 +265,7 @@ module Selenium
|
|
|
246
265
|
#
|
|
247
266
|
|
|
248
267
|
def [](sel)
|
|
249
|
-
if sel.
|
|
250
|
-
sel = { :id => sel }
|
|
251
|
-
end
|
|
268
|
+
sel = {id: sel} if sel.is_a?(String) || sel.is_a?(Symbol)
|
|
252
269
|
|
|
253
270
|
find_element sel
|
|
254
271
|
end
|
|
@@ -266,16 +283,26 @@ module Selenium
|
|
|
266
283
|
# @see SearchContext
|
|
267
284
|
#
|
|
268
285
|
|
|
269
|
-
def ref
|
|
270
|
-
nil
|
|
271
|
-
end
|
|
286
|
+
def ref; end
|
|
272
287
|
|
|
273
288
|
private
|
|
274
289
|
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
290
|
+
attr_reader :bridge
|
|
291
|
+
|
|
292
|
+
def service_url(opts)
|
|
293
|
+
@service = opts.delete(:service)
|
|
294
|
+
%i[driver_opts driver_path port].each do |key|
|
|
295
|
+
next unless opts.key? key
|
|
278
296
|
|
|
297
|
+
WebDriver.logger.deprecate(":#{key}", ':service with an instance of Selenium::WebDriver::Service')
|
|
298
|
+
end
|
|
299
|
+
@service ||= Service.send(browser,
|
|
300
|
+
args: opts.delete(:driver_opts),
|
|
301
|
+
path: opts.delete(:driver_path),
|
|
302
|
+
port: opts.delete(:port))
|
|
303
|
+
@service.start
|
|
304
|
+
@service.uri
|
|
305
|
+
end
|
|
279
306
|
end # Driver
|
|
280
307
|
end # WebDriver
|
|
281
308
|
end # Selenium
|
|
@@ -0,0 +1,45 @@
|
|
|
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 DriverExtensions
|
|
23
|
+
module DownloadsFiles
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# Sets download path for Chromium.
|
|
27
|
+
#
|
|
28
|
+
# @param [String] path
|
|
29
|
+
#
|
|
30
|
+
|
|
31
|
+
def download_path=(path)
|
|
32
|
+
params = {
|
|
33
|
+
'cmd' => 'Page.setDownloadBehavior',
|
|
34
|
+
'params' => {
|
|
35
|
+
'behavior' => 'allow',
|
|
36
|
+
'downloadPath' => path
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
@bridge.send_command(params)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end # DownloadsFiles
|
|
43
|
+
end # DriverExtensions
|
|
44
|
+
end # WebDriver
|
|
45
|
+
end # Selenium
|
|
@@ -0,0 +1,50 @@
|
|
|
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 DriverExtensions
|
|
23
|
+
module HasAddons
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# Installs addon.
|
|
27
|
+
#
|
|
28
|
+
# @param [String] path Full path to addon file
|
|
29
|
+
# @param [Boolean] temporary
|
|
30
|
+
# @return [String] identifier of installed addon
|
|
31
|
+
#
|
|
32
|
+
|
|
33
|
+
def install_addon(path, temporary = nil)
|
|
34
|
+
@bridge.install_addon(path, temporary)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
#
|
|
38
|
+
# Uninstalls addon.
|
|
39
|
+
#
|
|
40
|
+
# @param [String] id Identifier of installed addon
|
|
41
|
+
#
|
|
42
|
+
|
|
43
|
+
def uninstall_addon(id)
|
|
44
|
+
@bridge.uninstall_addon(id)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end # HasAddons
|
|
48
|
+
end # DriverExtensions
|
|
49
|
+
end # WebDriver
|
|
50
|
+
end # Selenium
|
|
@@ -0,0 +1,42 @@
|
|
|
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 DriverExtensions
|
|
23
|
+
module HasDebugger
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# Attaches debugger to session.
|
|
27
|
+
#
|
|
28
|
+
# @example
|
|
29
|
+
# driver.attach_debugger
|
|
30
|
+
# driver.execute_script('debugger')
|
|
31
|
+
#
|
|
32
|
+
# @return [Hash]
|
|
33
|
+
#
|
|
34
|
+
|
|
35
|
+
def attach_debugger
|
|
36
|
+
@bridge.attach_debugger
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end # HasDebugger
|
|
40
|
+
end # DriverExtensions
|
|
41
|
+
end # WebDriver
|
|
42
|
+
end # Selenium
|
|
@@ -1,25 +1,40 @@
|
|
|
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
|
+
|
|
1
20
|
module Selenium
|
|
2
21
|
module WebDriver
|
|
3
22
|
module DriverExtensions
|
|
4
|
-
|
|
5
23
|
module HasLocation
|
|
6
24
|
def location
|
|
7
|
-
@bridge.
|
|
25
|
+
@bridge.location
|
|
8
26
|
end
|
|
9
27
|
|
|
10
28
|
def location=(loc)
|
|
11
|
-
unless loc.
|
|
12
|
-
raise TypeError, "expected #{Location}, got #{loc.inspect}:#{loc.class}"
|
|
13
|
-
end
|
|
29
|
+
raise TypeError, "expected #{Location}, got #{loc.inspect}:#{loc.class}" unless loc.is_a?(Location)
|
|
14
30
|
|
|
15
|
-
@bridge.
|
|
31
|
+
@bridge.set_location loc.latitude, loc.longitude, loc.altitude
|
|
16
32
|
end
|
|
17
33
|
|
|
18
34
|
def set_location(lat, lon, alt)
|
|
19
35
|
self.location = Location.new(Float(lat), Float(lon), Float(alt))
|
|
20
36
|
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
end
|
|
37
|
+
end # HasLocation
|
|
38
|
+
end # DriverExtensions
|
|
39
|
+
end # WebDriver
|
|
40
|
+
end # Selenium
|
|
@@ -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 DriverExtensions
|
|
23
|
+
module HasNetworkConditions
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# Returns network conditions.
|
|
27
|
+
#
|
|
28
|
+
# @return [Hash]
|
|
29
|
+
#
|
|
30
|
+
|
|
31
|
+
def network_conditions
|
|
32
|
+
@bridge.network_conditions
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
#
|
|
36
|
+
# Sets network conditions
|
|
37
|
+
#
|
|
38
|
+
# @param [Hash] conditions
|
|
39
|
+
# @option conditions [Integer] :latency
|
|
40
|
+
# @option conditions [Integer] :throughput
|
|
41
|
+
# @option conditions [Boolean] :offline
|
|
42
|
+
#
|
|
43
|
+
|
|
44
|
+
def network_conditions=(conditions)
|
|
45
|
+
@bridge.network_conditions = conditions
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end # HasNetworkConditions
|
|
49
|
+
end # DriverExtensions
|
|
50
|
+
end # WebDriver
|
|
51
|
+
end # Selenium
|
|
@@ -0,0 +1,58 @@
|
|
|
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 DriverExtensions
|
|
23
|
+
module HasNetworkConnection
|
|
24
|
+
def network_connection_type
|
|
25
|
+
connection_value = @bridge.network_connection
|
|
26
|
+
|
|
27
|
+
connection_type = values_to_type[connection_value]
|
|
28
|
+
|
|
29
|
+
# In case the connection type is not recognized return the
|
|
30
|
+
# connection value.
|
|
31
|
+
connection_type || connection_value
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def network_connection_type=(connection_type)
|
|
35
|
+
raise ArgumentError, 'Invalid connection type' unless valid_type? connection_type
|
|
36
|
+
|
|
37
|
+
connection_value = type_to_values[connection_type]
|
|
38
|
+
|
|
39
|
+
@bridge.network_connection = connection_value
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def type_to_values
|
|
45
|
+
{airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def values_to_type
|
|
49
|
+
type_to_values.invert
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def valid_type?(type)
|
|
53
|
+
type_to_values.key? type
|
|
54
|
+
end
|
|
55
|
+
end # HasNetworkConnection
|
|
56
|
+
end # DriverExtensions
|
|
57
|
+
end # WebDriver
|
|
58
|
+
end # Selenium
|
|
@@ -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 DriverExtensions
|
|
23
|
+
module HasPermissions
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# Returns permissions.
|
|
27
|
+
#
|
|
28
|
+
# @return [Hash]
|
|
29
|
+
#
|
|
30
|
+
|
|
31
|
+
def permissions
|
|
32
|
+
@bridge.permissions
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
#
|
|
36
|
+
# Sets permissions.
|
|
37
|
+
#
|
|
38
|
+
# @example
|
|
39
|
+
# driver.permissions = {'getUserMedia' => true}
|
|
40
|
+
#
|
|
41
|
+
# @param [Hash<Symbol, Boolean>] permissions
|
|
42
|
+
#
|
|
43
|
+
|
|
44
|
+
def permissions=(permissions)
|
|
45
|
+
@bridge.permissions = permissions
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
end # HasPermissions
|
|
49
|
+
end # DriverExtensions
|
|
50
|
+
end # WebDriver
|
|
51
|
+
end # Selenium
|
|
@@ -1,13 +1,30 @@
|
|
|
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
|
+
|
|
1
20
|
module Selenium
|
|
2
21
|
module WebDriver
|
|
3
22
|
module DriverExtensions
|
|
4
23
|
module HasRemoteStatus
|
|
5
|
-
|
|
6
24
|
def remote_status
|
|
7
25
|
@bridge.status
|
|
8
26
|
end
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
end
|
|
27
|
+
end # HasRemoteStatus
|
|
28
|
+
end # DriverExtensions
|
|
29
|
+
end # WebDriver
|
|
30
|
+
end # Selenium
|