selenium-webdriver 3.0.1 → 3.0.2
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.
- data/CHANGES +17 -0
- data/lib/selenium/webdriver/chrome.rb +13 -13
- data/lib/selenium/webdriver/chrome/bridge.rb +4 -3
- data/lib/selenium/webdriver/chrome/service.rb +6 -4
- data/lib/selenium/webdriver/common.rb +1 -0
- data/lib/selenium/webdriver/common/driver.rb +1 -1
- data/lib/selenium/webdriver/common/element.rb +14 -0
- data/lib/selenium/webdriver/common/options.rb +12 -10
- data/lib/selenium/webdriver/common/port_prober.rb +2 -1
- data/lib/selenium/webdriver/common/service.rb +23 -8
- data/lib/selenium/webdriver/common/w3c_options.rb +45 -0
- data/lib/selenium/webdriver/edge.rb +13 -13
- data/lib/selenium/webdriver/edge/bridge.rb +98 -1
- data/lib/selenium/webdriver/edge/service.rb +6 -4
- data/lib/selenium/webdriver/firefox.rb +13 -13
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/service.rb +10 -4
- data/lib/selenium/webdriver/firefox/w3c_bridge.rb +2 -1
- data/lib/selenium/webdriver/ie.rb +13 -13
- data/lib/selenium/webdriver/ie/bridge.rb +3 -1
- data/lib/selenium/webdriver/ie/service.rb +6 -4
- data/lib/selenium/webdriver/phantomjs.rb +13 -9
- data/lib/selenium/webdriver/phantomjs/bridge.rb +2 -1
- data/lib/selenium/webdriver/phantomjs/service.rb +2 -4
- data/lib/selenium/webdriver/remote/bridge.rb +102 -108
- data/lib/selenium/webdriver/remote/commands.rb +188 -185
- data/lib/selenium/webdriver/remote/w3c_bridge.rb +75 -94
- data/lib/selenium/webdriver/remote/w3c_capabilities.rb +3 -3
- data/lib/selenium/webdriver/remote/w3c_commands.rb +108 -104
- data/lib/selenium/webdriver/safari.rb +14 -13
- data/lib/selenium/webdriver/safari/bridge.rb +2 -1
- data/lib/selenium/webdriver/safari/service.rb +16 -4
- data/selenium-webdriver.gemspec +1 -1
- metadata +3 -4
- data/Gemfile.lock +0 -53
- data/lib/selenium/webdriver/edge/legacy_support.rb +0 -117
@@ -26,13 +26,15 @@ module Selenium
|
|
26
26
|
|
27
27
|
class Service < WebDriver::Service
|
28
28
|
DEFAULT_PORT = 17556
|
29
|
+
@executable = 'MicrosoftWebDriver'.freeze
|
30
|
+
@missing_text = <<-ERROR.gsub(/\n +| {2,}/, ' ').freeze
|
31
|
+
Unable to find MicrosoftWebDriver. Please download the server from
|
32
|
+
https://www.microsoft.com/en-us/download/details.aspx?id=48212 and place it somewhere on your PATH.
|
33
|
+
More info at https://github.com/SeleniumHQ/selenium/wiki/MicrosoftWebDriver.
|
34
|
+
ERROR
|
29
35
|
|
30
36
|
private
|
31
37
|
|
32
|
-
def stop_server
|
33
|
-
connect_to_server { |http| http.head('/shutdown') }
|
34
|
-
end
|
35
|
-
|
36
38
|
def start_process
|
37
39
|
server_command = [@executable_path, "--port=#{@port}", *@extra_args]
|
38
40
|
@process = ChildProcess.build(*server_command)
|
@@ -41,25 +41,25 @@ module Selenium
|
|
41
41
|
DEFAULT_ASSUME_UNTRUSTED_ISSUER = true
|
42
42
|
DEFAULT_LOAD_NO_FOCUS_LIB = false
|
43
43
|
|
44
|
-
MISSING_TEXT = <<-ERROR.tr("\n", '').freeze
|
45
|
-
Unable to find Mozilla geckodriver. Please download the server from
|
46
|
-
https://github.com/mozilla/geckodriver/releases and place it
|
47
|
-
somewhere on your PATH. More info at https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver.
|
48
|
-
ERROR
|
49
|
-
|
50
44
|
def self.driver_path=(path)
|
45
|
+
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
|
46
|
+
[DEPRECATION] `driver_path=` is deprecated. Pass the driver path as an option instead.
|
47
|
+
e.g. Selenium::WebDriver.for :firefox, driver_path: '/path'
|
48
|
+
DEPRECATE
|
49
|
+
|
51
50
|
Platform.assert_executable path
|
52
51
|
@driver_path = path
|
53
52
|
end
|
54
53
|
|
55
|
-
def self.driver_path
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
path
|
54
|
+
def self.driver_path(warning = true)
|
55
|
+
if warning
|
56
|
+
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
|
57
|
+
[DEPRECATION] `driver_path` is deprecated. Pass the driver path as an option instead.
|
58
|
+
e.g. Selenium::WebDriver.for :firefox, driver_path: '/path'
|
59
|
+
DEPRECATE
|
62
60
|
end
|
61
|
+
|
62
|
+
@driver_path ||= nil
|
63
63
|
end
|
64
64
|
|
65
65
|
def self.path=(path)
|
Binary file
|
@@ -26,6 +26,16 @@ module Selenium
|
|
26
26
|
|
27
27
|
class Service < WebDriver::Service
|
28
28
|
DEFAULT_PORT = 4444
|
29
|
+
@executable = 'geckodriver*'.freeze
|
30
|
+
@missing_text = <<-ERROR.gsub(/\n +| {2,}/, ' ').freeze
|
31
|
+
Unable to find Mozilla geckodriver. Please download the server from
|
32
|
+
https://github.com/mozilla/geckodriver/releases and place it somewhere on your PATH.
|
33
|
+
More info at https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver.
|
34
|
+
ERROR
|
35
|
+
|
36
|
+
def stop
|
37
|
+
stop_process
|
38
|
+
end
|
29
39
|
|
30
40
|
private
|
31
41
|
|
@@ -54,10 +64,6 @@ module Selenium
|
|
54
64
|
end
|
55
65
|
end
|
56
66
|
|
57
|
-
def stop_server
|
58
|
-
connect_to_server { |http| http.head('/shutdown') }
|
59
|
-
end
|
60
|
-
|
61
67
|
def cannot_connect_error_text
|
62
68
|
"unable to connect to Mozilla geckodriver #{@host}:#{@port}"
|
63
69
|
end
|
@@ -27,7 +27,8 @@ module Selenium
|
|
27
27
|
opts[:desired_capabilities] = create_capabilities(opts)
|
28
28
|
service_args = opts.delete(:service_args) || {}
|
29
29
|
|
30
|
-
|
30
|
+
driver_path = opts.delete(:driver_path) || Firefox.driver_path(false)
|
31
|
+
@service = Service.new(driver_path, port, *extract_service_args(service_args))
|
31
32
|
@service.start
|
32
33
|
opts[:url] = @service.uri
|
33
34
|
|
@@ -23,25 +23,25 @@ require 'selenium/webdriver/ie/service'
|
|
23
23
|
module Selenium
|
24
24
|
module WebDriver
|
25
25
|
module IE
|
26
|
-
MISSING_TEXT = <<-ERROR.tr("\n", '').freeze
|
27
|
-
Unable to find IEDriverServer. Please download the server from
|
28
|
-
http://selenium-release.storage.googleapis.com/index.html and place it
|
29
|
-
somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver.
|
30
|
-
ERROR
|
31
|
-
|
32
26
|
def self.driver_path=(path)
|
27
|
+
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
|
28
|
+
[DEPRECATION] `driver_path=` is deprecated. Pass the driver path as an option instead.
|
29
|
+
e.g. Selenium::WebDriver.for :ie, driver_path: '/path'
|
30
|
+
DEPRECATE
|
31
|
+
|
33
32
|
Platform.assert_executable path
|
34
33
|
@driver_path = path
|
35
34
|
end
|
36
35
|
|
37
|
-
def self.driver_path
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
path
|
36
|
+
def self.driver_path(warning = true)
|
37
|
+
if warning
|
38
|
+
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
|
39
|
+
[DEPRECATION] `driver_path` is deprecated. Pass the driver path as an option instead.
|
40
|
+
e.g. Selenium::WebDriver.for :ie, driver_path: '/path'
|
41
|
+
DEPRECATE
|
44
42
|
end
|
43
|
+
|
44
|
+
@driver_path ||= nil
|
45
45
|
end
|
46
46
|
end # IE
|
47
47
|
end # WebDriver
|
@@ -29,7 +29,9 @@ module Selenium
|
|
29
29
|
port = opts.delete(:port) || Service::DEFAULT_PORT
|
30
30
|
service_args = opts.delete(:service_args) || {}
|
31
31
|
service_args = match_legacy(opts, service_args)
|
32
|
-
|
32
|
+
driver_path = opts.delete(:driver_path) || IE.driver_path(false)
|
33
|
+
|
34
|
+
@service = Service.new(driver_path, port, *extract_service_args(service_args))
|
33
35
|
@service.start
|
34
36
|
opts[:url] = @service.uri
|
35
37
|
|
@@ -26,13 +26,15 @@ module Selenium
|
|
26
26
|
|
27
27
|
class Service < WebDriver::Service
|
28
28
|
DEFAULT_PORT = 5555
|
29
|
+
@executable = 'IEDriverServer'.freeze
|
30
|
+
@missing_text = <<-ERROR.gsub(/\n +| {2,}/, ' ').freeze
|
31
|
+
Unable to find IEDriverServer. Please download the server from
|
32
|
+
http://selenium-release.storage.googleapis.com/index.html and place it somewhere on your PATH.
|
33
|
+
More info at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver.
|
34
|
+
ERROR
|
29
35
|
|
30
36
|
private
|
31
37
|
|
32
|
-
def stop_server
|
33
|
-
# server can only be stopped as process
|
34
|
-
end
|
35
|
-
|
36
38
|
def start_process
|
37
39
|
server_command = [@executable_path, "--port=#{@port}", *@extra_args]
|
38
40
|
@process = ChildProcess.new(*server_command)
|
@@ -25,21 +25,25 @@ require 'selenium/webdriver/phantomjs/bridge'
|
|
25
25
|
module Selenium
|
26
26
|
module WebDriver
|
27
27
|
module PhantomJS
|
28
|
-
MISSING_TEXT = 'Unable to find phantomjs executable.'.freeze
|
29
|
-
|
30
28
|
def self.path=(path)
|
29
|
+
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
|
30
|
+
[DEPRECATION] `path=` is deprecated. Pass the driver path as an option instead.
|
31
|
+
e.g. Selenium::WebDriver.for :phantomjs, driver_path: '/path'
|
32
|
+
DEPRECATE
|
33
|
+
|
31
34
|
Platform.assert_executable path
|
32
35
|
@path = path
|
33
36
|
end
|
34
37
|
|
35
|
-
def self.path
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
path
|
38
|
+
def self.path(warning = true)
|
39
|
+
if warning
|
40
|
+
warn <<-DEPRECATE.gsub(/\n +| {2,}/, ' ').freeze
|
41
|
+
[DEPRECATION] `path` is deprecated. Pass the driver path as an option instead.
|
42
|
+
e.g. Selenium::WebDriver.for :phantomjs, driver_path: '/path'
|
43
|
+
DEPRECATE
|
42
44
|
end
|
45
|
+
|
46
|
+
@path ||= nil
|
43
47
|
end
|
44
48
|
end # PhantomJS
|
45
49
|
end # WebDriver
|
@@ -30,8 +30,9 @@ module Selenium
|
|
30
30
|
opts[:desired_capabilities] ||= Remote::Capabilities.phantomjs
|
31
31
|
|
32
32
|
unless opts.key?(:url)
|
33
|
+
driver_path = opts.delete(:driver_path) || PhantomJS.path(false)
|
33
34
|
args = opts.delete(:args) || opts[:desired_capabilities]['phantomjs.cli.args']
|
34
|
-
@service = Service.new(
|
35
|
+
@service = Service.new(driver_path, port, *args)
|
35
36
|
@service.start
|
36
37
|
opts[:url] = @service.uri
|
37
38
|
end
|
@@ -26,6 +26,8 @@ module Selenium
|
|
26
26
|
|
27
27
|
class Service < WebDriver::Service
|
28
28
|
DEFAULT_PORT = 8910
|
29
|
+
@executable = 'phantomjs'.freeze
|
30
|
+
@missing_text = 'Unable to find phantomjs. Please download from http://phantomjs.org/download.html'.freeze
|
29
31
|
|
30
32
|
private
|
31
33
|
|
@@ -53,10 +55,6 @@ module Selenium
|
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
|
-
def stop_server
|
57
|
-
connect_to_server { |http| http.get('/shutdown') }
|
58
|
-
end
|
59
|
-
|
60
58
|
def cannot_connect_error_text
|
61
59
|
"unable to connect to phantomjs @ #{uri} after #{START_TIMEOUT} seconds"
|
62
60
|
end
|
@@ -29,25 +29,6 @@ module Selenium
|
|
29
29
|
class Bridge
|
30
30
|
include BridgeHelper
|
31
31
|
|
32
|
-
# TODO: constant shouldn't be modified in class
|
33
|
-
COMMANDS = {}
|
34
|
-
|
35
|
-
#
|
36
|
-
# Defines a wrapper method for a command, which ultimately calls #execute.
|
37
|
-
#
|
38
|
-
# @param name [Symbol]
|
39
|
-
# name of the resulting method
|
40
|
-
# @param url [String]
|
41
|
-
# a URL template, which can include some arguments, much like the definitions on the server.
|
42
|
-
# the :session_id parameter is implicitly handled, but the remainder will become required method arguments.
|
43
|
-
# @param verb [Symbol]
|
44
|
-
# the appropriate http verb, such as :get, :post, or :delete
|
45
|
-
#
|
46
|
-
|
47
|
-
def self.command(name, verb, url)
|
48
|
-
COMMANDS[name] = [verb, url.freeze]
|
49
|
-
end
|
50
|
-
|
51
32
|
attr_accessor :context, :http, :file_detector
|
52
33
|
attr_reader :capabilities
|
53
34
|
|
@@ -112,6 +93,10 @@ module Selenium
|
|
112
93
|
]
|
113
94
|
end
|
114
95
|
|
96
|
+
def commands(command)
|
97
|
+
COMMANDS[command]
|
98
|
+
end
|
99
|
+
|
115
100
|
#
|
116
101
|
# Returns the current session ID.
|
117
102
|
#
|
@@ -121,7 +106,7 @@ module Selenium
|
|
121
106
|
end
|
122
107
|
|
123
108
|
def create_session(desired_capabilities)
|
124
|
-
resp = raw_execute :
|
109
|
+
resp = raw_execute :new_session, {}, {desiredCapabilities: desired_capabilities}
|
125
110
|
@session_id = resp['sessionId']
|
126
111
|
return Capabilities.json_create resp['value'] if @session_id
|
127
112
|
|
@@ -137,19 +122,19 @@ module Selenium
|
|
137
122
|
end
|
138
123
|
|
139
124
|
def session_capabilities
|
140
|
-
Capabilities.json_create execute(:
|
125
|
+
Capabilities.json_create execute(:get_capabilities)
|
141
126
|
end
|
142
127
|
|
143
128
|
def implicit_wait_timeout=(milliseconds)
|
144
|
-
execute :
|
129
|
+
execute :implicitly_wait, {}, {ms: milliseconds}
|
145
130
|
end
|
146
131
|
|
147
132
|
def script_timeout=(milliseconds)
|
148
|
-
execute :
|
133
|
+
execute :set_script_timeout, {}, {ms: milliseconds}
|
149
134
|
end
|
150
135
|
|
151
136
|
def timeout(type, milliseconds)
|
152
|
-
execute :
|
137
|
+
execute :set_timeout, {}, {type: type, ms: milliseconds}
|
153
138
|
end
|
154
139
|
|
155
140
|
#
|
@@ -157,23 +142,23 @@ module Selenium
|
|
157
142
|
#
|
158
143
|
|
159
144
|
def accept_alert
|
160
|
-
execute :
|
145
|
+
execute :accept_alert
|
161
146
|
end
|
162
147
|
|
163
148
|
def dismiss_alert
|
164
|
-
execute :
|
149
|
+
execute :dismiss_alert
|
165
150
|
end
|
166
151
|
|
167
152
|
def alert=(keys)
|
168
|
-
execute :
|
153
|
+
execute :set_alert_value, {}, {text: keys.to_s}
|
169
154
|
end
|
170
155
|
|
171
156
|
def alert_text
|
172
|
-
execute :
|
157
|
+
execute :get_alert_text
|
173
158
|
end
|
174
159
|
|
175
160
|
def authentication(credentials)
|
176
|
-
execute :
|
161
|
+
execute :set_authentication, {}, credentials
|
177
162
|
end
|
178
163
|
|
179
164
|
#
|
@@ -181,35 +166,35 @@ module Selenium
|
|
181
166
|
#
|
182
167
|
|
183
168
|
def go_back
|
184
|
-
execute :
|
169
|
+
execute :go_back
|
185
170
|
end
|
186
171
|
|
187
172
|
def go_forward
|
188
|
-
execute :
|
173
|
+
execute :go_forward
|
189
174
|
end
|
190
175
|
|
191
176
|
def url
|
192
|
-
execute :
|
177
|
+
execute :get_current_url
|
193
178
|
end
|
194
179
|
|
195
180
|
def title
|
196
|
-
execute :
|
181
|
+
execute :get_title
|
197
182
|
end
|
198
183
|
|
199
184
|
def page_source
|
200
|
-
execute :
|
185
|
+
execute :get_page_source
|
201
186
|
end
|
202
187
|
|
203
188
|
def switch_to_window(name)
|
204
|
-
execute :
|
189
|
+
execute :switch_to_window, {}, {name: name}
|
205
190
|
end
|
206
191
|
|
207
192
|
def switch_to_frame(id)
|
208
|
-
execute :
|
193
|
+
execute :switch_to_frame, {}, {id: id}
|
209
194
|
end
|
210
195
|
|
211
196
|
def switch_to_parent_frame
|
212
|
-
execute :
|
197
|
+
execute :switch_to_parent_frame
|
213
198
|
end
|
214
199
|
|
215
200
|
def switch_to_default_content
|
@@ -237,36 +222,36 @@ module Selenium
|
|
237
222
|
#
|
238
223
|
|
239
224
|
def window_handles
|
240
|
-
execute :
|
225
|
+
execute :get_window_handles
|
241
226
|
end
|
242
227
|
|
243
228
|
def window_handle
|
244
|
-
execute :
|
229
|
+
execute :get_current_window_handle
|
245
230
|
end
|
246
231
|
|
247
232
|
def resize_window(width, height, handle = :current)
|
248
|
-
execute :
|
233
|
+
execute :set_window_size, {window_handle: handle},
|
249
234
|
{width: width,
|
250
235
|
height: height}
|
251
236
|
end
|
252
237
|
|
253
238
|
def maximize_window(handle = :current)
|
254
|
-
execute :
|
239
|
+
execute :maximize_window, window_handle: handle
|
255
240
|
end
|
256
241
|
|
257
242
|
def window_size(handle = :current)
|
258
|
-
data = execute :
|
243
|
+
data = execute :get_window_size, window_handle: handle
|
259
244
|
|
260
245
|
Dimension.new data['width'], data['height']
|
261
246
|
end
|
262
247
|
|
263
248
|
def reposition_window(x, y, handle = :current)
|
264
|
-
execute :
|
249
|
+
execute :set_window_position, {window_handle: handle},
|
265
250
|
{x: x, y: y}
|
266
251
|
end
|
267
252
|
|
268
253
|
def window_position(handle = :current)
|
269
|
-
data = execute :
|
254
|
+
data = execute :get_window_position, window_handle: handle
|
270
255
|
|
271
256
|
Point.new data['x'], data['y']
|
272
257
|
end
|
@@ -281,68 +266,68 @@ module Selenium
|
|
281
266
|
|
282
267
|
def local_storage_item(key, value = nil)
|
283
268
|
if value
|
284
|
-
execute :
|
269
|
+
execute :set_local_storage_item, {}, {key: key, value: value}
|
285
270
|
else
|
286
|
-
execute :
|
271
|
+
execute :get_local_storage_item, key: key
|
287
272
|
end
|
288
273
|
end
|
289
274
|
|
290
275
|
def remove_local_storage_item(key)
|
291
|
-
execute :
|
276
|
+
execute :remove_local_storage_item, key: key
|
292
277
|
end
|
293
278
|
|
294
279
|
def local_storage_keys
|
295
|
-
execute :
|
280
|
+
execute :get_local_storage_keys
|
296
281
|
end
|
297
282
|
|
298
283
|
def clear_local_storage
|
299
|
-
execute :
|
284
|
+
execute :clear_local_storage
|
300
285
|
end
|
301
286
|
|
302
287
|
def local_storage_size
|
303
|
-
execute :
|
288
|
+
execute :get_local_storage_size
|
304
289
|
end
|
305
290
|
|
306
291
|
def session_storage_item(key, value = nil)
|
307
292
|
if value
|
308
|
-
execute :
|
293
|
+
execute :set_session_storage_item, {}, {key: key, value: value}
|
309
294
|
else
|
310
|
-
execute :
|
295
|
+
execute :get_session_storage_item, key: key
|
311
296
|
end
|
312
297
|
end
|
313
298
|
|
314
299
|
def remove_session_storage_item(key)
|
315
|
-
execute :
|
300
|
+
execute :remove_session_storage_item, key: key
|
316
301
|
end
|
317
302
|
|
318
303
|
def session_storage_keys
|
319
|
-
execute :
|
304
|
+
execute :get_session_storage_keys
|
320
305
|
end
|
321
306
|
|
322
307
|
def clear_session_storage
|
323
|
-
execute :
|
308
|
+
execute :clear_session_storage
|
324
309
|
end
|
325
310
|
|
326
311
|
def session_storage_size
|
327
|
-
execute :
|
312
|
+
execute :get_session_storage_size
|
328
313
|
end
|
329
314
|
|
330
315
|
def location
|
331
|
-
obj = execute(:
|
316
|
+
obj = execute(:get_location) || {}
|
332
317
|
Location.new obj['latitude'], obj['longitude'], obj['altitude']
|
333
318
|
end
|
334
319
|
|
335
320
|
def set_location(lat, lon, alt)
|
336
321
|
loc = {latitude: lat, longitude: lon, altitude: alt}
|
337
|
-
execute :
|
322
|
+
execute :set_location, {}, {location: loc}
|
338
323
|
end
|
339
324
|
|
340
325
|
def network_connection
|
341
|
-
execute :
|
326
|
+
execute :get_network_connection
|
342
327
|
end
|
343
328
|
|
344
329
|
def network_connection=(type)
|
345
|
-
execute :
|
330
|
+
execute :set_network_connection, {}, {parameters: {type: type}}
|
346
331
|
end
|
347
332
|
|
348
333
|
#
|
@@ -352,14 +337,14 @@ module Selenium
|
|
352
337
|
def execute_script(script, *args)
|
353
338
|
assert_javascript_enabled
|
354
339
|
|
355
|
-
result = execute :
|
340
|
+
result = execute :execute_script, {}, {script: script, args: args}
|
356
341
|
unwrap_script_result result
|
357
342
|
end
|
358
343
|
|
359
344
|
def execute_async_script(script, *args)
|
360
345
|
assert_javascript_enabled
|
361
346
|
|
362
|
-
result = execute :
|
347
|
+
result = execute :execute_async_script, {}, {script: script, args: args}
|
363
348
|
unwrap_script_result result
|
364
349
|
end
|
365
350
|
|
@@ -367,20 +352,24 @@ module Selenium
|
|
367
352
|
# cookies
|
368
353
|
#
|
369
354
|
|
355
|
+
def options
|
356
|
+
@options ||= WebDriver::Options.new(self)
|
357
|
+
end
|
358
|
+
|
370
359
|
def add_cookie(cookie)
|
371
|
-
execute :
|
360
|
+
execute :add_cookie, {}, {cookie: cookie}
|
372
361
|
end
|
373
362
|
|
374
363
|
def delete_cookie(name)
|
375
|
-
execute :
|
364
|
+
execute :delete_cookie, name: name
|
376
365
|
end
|
377
366
|
|
378
367
|
def cookies
|
379
|
-
execute :
|
368
|
+
execute :get_cookies
|
380
369
|
end
|
381
370
|
|
382
371
|
def delete_all_cookies
|
383
|
-
execute :
|
372
|
+
execute :delete_all_cookies
|
384
373
|
end
|
385
374
|
|
386
375
|
#
|
@@ -388,7 +377,7 @@ module Selenium
|
|
388
377
|
#
|
389
378
|
|
390
379
|
def click_element(element)
|
391
|
-
execute :
|
380
|
+
execute :click_element, id: element
|
392
381
|
end
|
393
382
|
|
394
383
|
def click
|
@@ -396,7 +385,7 @@ module Selenium
|
|
396
385
|
end
|
397
386
|
|
398
387
|
def double_click
|
399
|
-
execute :
|
388
|
+
execute :double_click
|
400
389
|
end
|
401
390
|
|
402
391
|
def context_click
|
@@ -404,11 +393,11 @@ module Selenium
|
|
404
393
|
end
|
405
394
|
|
406
395
|
def mouse_down
|
407
|
-
execute :
|
396
|
+
execute :mouse_down
|
408
397
|
end
|
409
398
|
|
410
399
|
def mouse_up
|
411
|
-
execute :
|
400
|
+
execute :mouse_up
|
412
401
|
end
|
413
402
|
|
414
403
|
def mouse_move_to(element, x = nil, y = nil)
|
@@ -419,11 +408,11 @@ module Selenium
|
|
419
408
|
params[:yoffset] = y
|
420
409
|
end
|
421
410
|
|
422
|
-
execute :
|
411
|
+
execute :mouse_move_to, {}, params
|
423
412
|
end
|
424
413
|
|
425
414
|
def send_keys_to_active_element(key)
|
426
|
-
execute :
|
415
|
+
execute :send_keys_to_active_element, {}, {value: key}
|
427
416
|
end
|
428
417
|
|
429
418
|
def send_keys_to_element(element, keys)
|
@@ -432,7 +421,7 @@ module Selenium
|
|
432
421
|
keys = upload(local_file) if local_file
|
433
422
|
end
|
434
423
|
|
435
|
-
execute :
|
424
|
+
execute :send_keys_to_element, {id: element}, {value: Array(keys)}
|
436
425
|
end
|
437
426
|
|
438
427
|
def upload(local_file)
|
@@ -440,72 +429,72 @@ module Selenium
|
|
440
429
|
raise Error::WebDriverError, "you may only upload files: #{local_file.inspect}"
|
441
430
|
end
|
442
431
|
|
443
|
-
execute :
|
432
|
+
execute :upload_file, {}, {file: Zipper.zip_file(local_file)}
|
444
433
|
end
|
445
434
|
|
446
435
|
def clear_element(element)
|
447
|
-
execute :
|
436
|
+
execute :clear_element, id: element
|
448
437
|
end
|
449
438
|
|
450
439
|
def submit_element(element)
|
451
|
-
execute :
|
440
|
+
execute :submit_element, id: element
|
452
441
|
end
|
453
442
|
|
454
443
|
def drag_element(element, right_by, down_by)
|
455
|
-
execute :
|
444
|
+
execute :drag_element, {id: element}, {x: right_by, y: down_by}
|
456
445
|
end
|
457
446
|
|
458
447
|
def touch_single_tap(element)
|
459
|
-
execute :
|
448
|
+
execute :touch_single_tap, {}, {element: element}
|
460
449
|
end
|
461
450
|
|
462
451
|
def touch_double_tap(element)
|
463
|
-
execute :
|
452
|
+
execute :touch_double_tap, {}, {element: element}
|
464
453
|
end
|
465
454
|
|
466
455
|
def touch_long_press(element)
|
467
|
-
execute :
|
456
|
+
execute :touch_long_press, {}, {element: element}
|
468
457
|
end
|
469
458
|
|
470
459
|
def touch_down(x, y)
|
471
|
-
execute :
|
460
|
+
execute :touch_down, {}, {x: x, y: y}
|
472
461
|
end
|
473
462
|
|
474
463
|
def touch_up(x, y)
|
475
|
-
execute :
|
464
|
+
execute :touch_up, {}, {x: x, y: y}
|
476
465
|
end
|
477
466
|
|
478
467
|
def touch_move(x, y)
|
479
|
-
execute :
|
468
|
+
execute :touch_move, {}, {x: x, y: y}
|
480
469
|
end
|
481
470
|
|
482
471
|
def touch_scroll(element, x, y)
|
483
472
|
if element
|
484
|
-
execute :
|
473
|
+
execute :touch_scroll, {}, {element: element,
|
485
474
|
xoffset: x,
|
486
475
|
yoffset: y}
|
487
476
|
else
|
488
|
-
execute :
|
477
|
+
execute :touch_scroll, {}, {xoffset: x, yoffset: y}
|
489
478
|
end
|
490
479
|
end
|
491
480
|
|
492
481
|
def touch_flick(xspeed, yspeed)
|
493
|
-
execute :
|
482
|
+
execute :touch_flick, {}, {xspeed: xspeed, yspeed: yspeed}
|
494
483
|
end
|
495
484
|
|
496
485
|
def touch_element_flick(element, right_by, down_by, speed)
|
497
|
-
execute :
|
486
|
+
execute :touch_flick, {}, {element: element,
|
498
487
|
xoffset: right_by,
|
499
488
|
yoffset: down_by,
|
500
489
|
speed: speed}
|
501
490
|
end
|
502
491
|
|
503
492
|
def screen_orientation=(orientation)
|
504
|
-
execute :
|
493
|
+
execute :set_screen_orientation, {}, {orientation: orientation}
|
505
494
|
end
|
506
495
|
|
507
496
|
def screen_orientation
|
508
|
-
execute :
|
497
|
+
execute :get_screen_orientation
|
509
498
|
end
|
510
499
|
|
511
500
|
#
|
@@ -513,12 +502,12 @@ module Selenium
|
|
513
502
|
#
|
514
503
|
|
515
504
|
def available_log_types
|
516
|
-
types = execute :
|
505
|
+
types = execute :get_available_log_types
|
517
506
|
Array(types).map(&:to_sym)
|
518
507
|
end
|
519
508
|
|
520
509
|
def log(type)
|
521
|
-
data = execute :
|
510
|
+
data = execute :get_log, {}, {type: type.to_s}
|
522
511
|
|
523
512
|
Array(data).map do |l|
|
524
513
|
begin
|
@@ -534,53 +523,58 @@ module Selenium
|
|
534
523
|
#
|
535
524
|
|
536
525
|
def element_tag_name(element)
|
537
|
-
execute :
|
526
|
+
execute :get_element_tag_name, id: element
|
538
527
|
end
|
539
528
|
|
540
529
|
def element_attribute(element, name)
|
541
|
-
execute :
|
530
|
+
execute :get_element_attribute, id: element.ref, name: name
|
531
|
+
end
|
532
|
+
|
533
|
+
# Backwards compatibility for w3c
|
534
|
+
def element_property(element, name)
|
535
|
+
execute_script 'return arguments[0][arguments[1]]', element, name
|
542
536
|
end
|
543
537
|
|
544
538
|
def element_value(element)
|
545
|
-
execute :
|
539
|
+
execute :get_element_value, id: element
|
546
540
|
end
|
547
541
|
|
548
542
|
def element_text(element)
|
549
|
-
execute :
|
543
|
+
execute :get_element_text, id: element
|
550
544
|
end
|
551
545
|
|
552
546
|
def element_location(element)
|
553
|
-
data = execute :
|
547
|
+
data = execute :get_element_location, id: element
|
554
548
|
|
555
549
|
Point.new data['x'], data['y']
|
556
550
|
end
|
557
551
|
|
558
552
|
def element_location_once_scrolled_into_view(element)
|
559
|
-
data = execute :
|
553
|
+
data = execute :get_element_location_once_scrolled_into_view, id: element
|
560
554
|
|
561
555
|
Point.new data['x'], data['y']
|
562
556
|
end
|
563
557
|
|
564
558
|
def element_size(element)
|
565
|
-
data = execute :
|
559
|
+
data = execute :get_element_size, id: element
|
566
560
|
|
567
561
|
Dimension.new data['width'], data['height']
|
568
562
|
end
|
569
563
|
|
570
564
|
def element_enabled?(element)
|
571
|
-
execute :
|
565
|
+
execute :is_element_enabled, id: element
|
572
566
|
end
|
573
567
|
|
574
568
|
def element_selected?(element)
|
575
|
-
execute :
|
569
|
+
execute :is_element_selected, id: element
|
576
570
|
end
|
577
571
|
|
578
572
|
def element_displayed?(element)
|
579
|
-
execute :
|
573
|
+
execute :is_element_displayed, id: element
|
580
574
|
end
|
581
575
|
|
582
576
|
def element_value_of_css_property(element, prop)
|
583
|
-
execute :
|
577
|
+
execute :get_element_value_of_css_property, id: element, property_name: prop
|
584
578
|
end
|
585
579
|
|
586
580
|
#
|
@@ -588,16 +582,16 @@ module Selenium
|
|
588
582
|
#
|
589
583
|
|
590
584
|
def active_element
|
591
|
-
Element.new self, element_id_from(execute(:
|
585
|
+
Element.new self, element_id_from(execute(:get_active_element))
|
592
586
|
end
|
593
587
|
|
594
588
|
alias_method :switch_to_active_element, :active_element
|
595
589
|
|
596
590
|
def find_element_by(how, what, parent = nil)
|
597
591
|
id = if parent
|
598
|
-
execute :
|
592
|
+
execute :find_child_element, {id: parent}, {using: how, value: what}
|
599
593
|
else
|
600
|
-
execute :
|
594
|
+
execute :find_element, {}, {using: how, value: what}
|
601
595
|
end
|
602
596
|
|
603
597
|
Element.new self, element_id_from(id)
|
@@ -605,9 +599,9 @@ module Selenium
|
|
605
599
|
|
606
600
|
def find_elements_by(how, what, parent = nil)
|
607
601
|
ids = if parent
|
608
|
-
execute :
|
602
|
+
execute :find_child_elements, {id: parent}, {using: how, value: what}
|
609
603
|
else
|
610
|
-
execute :
|
604
|
+
execute :find_elements, {}, {using: how, value: what}
|
611
605
|
end
|
612
606
|
|
613
607
|
ids.map { |id| Element.new self, element_id_from(id) }
|
@@ -638,7 +632,7 @@ module Selenium
|
|
638
632
|
#
|
639
633
|
|
640
634
|
def raw_execute(command, opts = {}, command_hash = nil)
|
641
|
-
verb, path =
|
635
|
+
verb, path = commands(command) || raise(ArgumentError, "unknown command: #{command.inspect}")
|
642
636
|
path = path.dup
|
643
637
|
|
644
638
|
path[':session_id'] = @session_id if path.include?(':session_id')
|