selenium-webdriver 4.0.0.alpha1 → 4.0.0.alpha2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +8 -1
  3. data/lib/selenium/webdriver/version.rb +1 -1
  4. metadata +2 -26
  5. data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
  6. data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +0 -36
  7. data/lib/selenium/webdriver/common/keyboard.rb +0 -70
  8. data/lib/selenium/webdriver/common/mouse.rb +0 -89
  9. data/lib/selenium/webdriver/common/options.rb +0 -177
  10. data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -78
  11. data/lib/selenium/webdriver/common/touch_screen.rb +0 -123
  12. data/lib/selenium/webdriver/common/w3c_action_builder.rb +0 -212
  13. data/lib/selenium/webdriver/common/w3c_manager.rb +0 -45
  14. data/lib/selenium/webdriver/common/w3c_options.rb +0 -45
  15. data/lib/selenium/webdriver/edge/bridge.rb +0 -76
  16. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  17. data/lib/selenium/webdriver/firefox/launcher.rb +0 -111
  18. data/lib/selenium/webdriver/firefox/legacy/driver.rb +0 -83
  19. data/lib/selenium/webdriver/firefox/marionette/bridge.rb +0 -49
  20. data/lib/selenium/webdriver/firefox/marionette/driver.rb +0 -90
  21. data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
  22. data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
  23. data/lib/selenium/webdriver/firefox/util.rb +0 -46
  24. data/lib/selenium/webdriver/remote/oss/bridge.rb +0 -594
  25. data/lib/selenium/webdriver/remote/oss/commands.rb +0 -223
  26. data/lib/selenium/webdriver/remote/w3c/bridge.rb +0 -605
  27. data/lib/selenium/webdriver/remote/w3c/capabilities.rb +0 -310
  28. data/lib/selenium/webdriver/remote/w3c/commands.rb +0 -157
@@ -1,46 +0,0 @@
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 Firefox
23
- # @api private
24
- module Util
25
- module_function
26
-
27
- def app_data_path
28
- case Platform.os
29
- when :windows
30
- "#{ENV['APPDATA']}\\Mozilla\\Firefox"
31
- when :macosx
32
- "#{Platform.home}/Library/Application Support/Firefox"
33
- when :unix, :linux
34
- "#{Platform.home}/.mozilla/firefox"
35
- else
36
- raise "Unknown os: #{Platform.os}"
37
- end
38
- end
39
-
40
- def stringified?(str)
41
- str =~ /^".*"$/
42
- end
43
- end # Util
44
- end # Firefox
45
- end # WebDriver
46
- end # Selenium
@@ -1,594 +0,0 @@
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
- module OSS
24
-
25
- #
26
- # Low level bridge to the remote server implementing JSON wire
27
- # protocol (OSS dialect), through which the rest of the API works.
28
- # @api private
29
- #
30
-
31
- class Bridge < Remote::Bridge
32
-
33
- def initialize(capabilities, session_id, **opts)
34
- @capabilities = capabilities
35
- @session_id = session_id
36
- super(opts)
37
- end
38
-
39
- def dialect
40
- :oss
41
- end
42
-
43
- def commands(command)
44
- COMMANDS[command]
45
- end
46
-
47
- def status
48
- execute :status
49
- end
50
-
51
- def get(url)
52
- execute :get, {}, {url: url}
53
- end
54
-
55
- def session_capabilities
56
- Capabilities.json_create execute(:get_capabilities)
57
- end
58
-
59
- def implicit_wait_timeout=(milliseconds)
60
- execute :implicitly_wait, {}, {ms: milliseconds}
61
- end
62
-
63
- def script_timeout=(milliseconds)
64
- execute :set_script_timeout, {}, {ms: milliseconds}
65
- end
66
-
67
- def timeout(type, milliseconds)
68
- execute :set_timeout, {}, {type: type, ms: milliseconds}
69
- end
70
-
71
- #
72
- # alerts
73
- #
74
-
75
- def accept_alert
76
- execute :accept_alert
77
- end
78
-
79
- def dismiss_alert
80
- execute :dismiss_alert
81
- end
82
-
83
- def alert=(keys)
84
- execute :set_alert_value, {}, {text: keys.to_s}
85
- end
86
-
87
- def alert_text
88
- execute :get_alert_text
89
- end
90
-
91
- def authentication(credentials)
92
- execute :set_authentication, {}, credentials
93
- end
94
-
95
- #
96
- # navigation
97
- #
98
-
99
- def go_back
100
- execute :go_back
101
- end
102
-
103
- def go_forward
104
- execute :go_forward
105
- end
106
-
107
- def url
108
- execute :get_current_url
109
- end
110
-
111
- def title
112
- execute :get_title
113
- end
114
-
115
- def page_source
116
- execute :get_page_source
117
- end
118
-
119
- def switch_to_window(name)
120
- execute :switch_to_window, {}, {name: name}
121
- end
122
-
123
- def switch_to_frame(id)
124
- execute :switch_to_frame, {}, {id: id}
125
- end
126
-
127
- def switch_to_parent_frame
128
- execute :switch_to_parent_frame
129
- end
130
-
131
- def switch_to_default_content
132
- switch_to_frame(nil)
133
- end
134
-
135
- def quit
136
- execute :quit
137
- http.close
138
- rescue *http.quit_errors
139
- end
140
-
141
- def close
142
- execute :close
143
- end
144
-
145
- def refresh
146
- execute :refresh
147
- end
148
-
149
- #
150
- # window handling
151
- #
152
-
153
- def window_handles
154
- execute :get_window_handles
155
- end
156
-
157
- def window_handle
158
- execute :get_current_window_handle
159
- end
160
-
161
- def resize_window(width, height, handle = :current)
162
- execute :set_window_size, {window_handle: handle},
163
- {width: width,
164
- height: height}
165
- end
166
-
167
- def maximize_window(handle = :current)
168
- execute :maximize_window, window_handle: handle
169
- end
170
-
171
- def window_size(handle = :current)
172
- data = execute :get_window_size, window_handle: handle
173
-
174
- Dimension.new data['width'], data['height']
175
- end
176
-
177
- def reposition_window(x, y, handle = :current)
178
- execute :set_window_position, {window_handle: handle},
179
- {x: x, y: y}
180
- end
181
-
182
- def window_position(handle = :current)
183
- data = execute :get_window_position, window_handle: handle
184
-
185
- Point.new data['x'], data['y']
186
- end
187
-
188
- def screenshot
189
- execute :screenshot
190
- end
191
-
192
- #
193
- # HTML 5
194
- #
195
-
196
- def local_storage_item(key, value = nil)
197
- if value
198
- execute :set_local_storage_item, {}, {key: key, value: value}
199
- else
200
- execute :get_local_storage_item, key: key
201
- end
202
- end
203
-
204
- def remove_local_storage_item(key)
205
- execute :remove_local_storage_item, key: key
206
- end
207
-
208
- def local_storage_keys
209
- execute :get_local_storage_keys
210
- end
211
-
212
- def clear_local_storage
213
- execute :clear_local_storage
214
- end
215
-
216
- def local_storage_size
217
- execute :get_local_storage_size
218
- end
219
-
220
- def session_storage_item(key, value = nil)
221
- if value
222
- execute :set_session_storage_item, {}, {key: key, value: value}
223
- else
224
- execute :get_session_storage_item, key: key
225
- end
226
- end
227
-
228
- def remove_session_storage_item(key)
229
- execute :remove_session_storage_item, key: key
230
- end
231
-
232
- def session_storage_keys
233
- execute :get_session_storage_keys
234
- end
235
-
236
- def clear_session_storage
237
- execute :clear_session_storage
238
- end
239
-
240
- def session_storage_size
241
- execute :get_session_storage_size
242
- end
243
-
244
- def location
245
- obj = execute(:get_location) || {}
246
- Location.new obj['latitude'], obj['longitude'], obj['altitude']
247
- end
248
-
249
- def set_location(lat, lon, alt)
250
- loc = {latitude: lat, longitude: lon, altitude: alt}
251
- execute :set_location, {}, {location: loc}
252
- end
253
-
254
- def network_connection
255
- execute :get_network_connection
256
- end
257
-
258
- def network_connection=(type)
259
- execute :set_network_connection, {}, {parameters: {type: type}}
260
- end
261
-
262
- #
263
- # javascript execution
264
- #
265
-
266
- def execute_script(script, *args)
267
- assert_javascript_enabled
268
-
269
- result = execute :execute_script, {}, {script: script, args: args}
270
- unwrap_script_result result
271
- end
272
-
273
- def execute_async_script(script, *args)
274
- assert_javascript_enabled
275
-
276
- result = execute :execute_async_script, {}, {script: script, args: args}
277
- unwrap_script_result result
278
- end
279
-
280
- #
281
- # cookies
282
- #
283
-
284
- def manage
285
- @manage ||= WebDriver::Manager.new(self)
286
- end
287
-
288
- def add_cookie(cookie)
289
- execute :add_cookie, {}, {cookie: cookie}
290
- end
291
-
292
- def delete_cookie(name)
293
- execute :delete_cookie, name: name
294
- end
295
-
296
- def cookies
297
- execute :get_cookies
298
- end
299
-
300
- def delete_all_cookies
301
- execute :delete_all_cookies
302
- end
303
-
304
- #
305
- # actions
306
- #
307
-
308
- #
309
- # @return [ActionBuilder]
310
- # @api public
311
- #
312
-
313
- def action
314
- ActionBuilder.new Mouse.new(self), Keyboard.new(self)
315
- end
316
-
317
- def mouse
318
- WebDriver.logger.deprecate 'Driver#mouse', 'driver.action.<command>.perform'
319
- Mouse.new self
320
- end
321
-
322
- def keyboard
323
- WebDriver.logger.deprecate 'Driver#keyboard', 'driver.action.<command>.perform'
324
- Keyboard.new self
325
- end
326
-
327
- def click_element(element)
328
- execute :click_element, id: element
329
- end
330
-
331
- def click
332
- execute :click, {}, {button: 0}
333
- end
334
-
335
- def double_click
336
- execute :double_click
337
- end
338
-
339
- def context_click
340
- execute :click, {}, {button: 2}
341
- end
342
-
343
- def mouse_down
344
- execute :mouse_down
345
- end
346
-
347
- def mouse_up
348
- execute :mouse_up
349
- end
350
-
351
- def mouse_move_to(element, x = nil, y = nil)
352
- params = {element: element}
353
-
354
- if x && y
355
- params[:xoffset] = x
356
- params[:yoffset] = y
357
- end
358
-
359
- execute :mouse_move_to, {}, params
360
- end
361
-
362
- def send_keys_to_active_element(key)
363
- execute :send_keys_to_active_element, {}, {value: key}
364
- end
365
-
366
- def send_keys_to_element(element, keys)
367
- # TODO: rework file detectors before Selenium 4.0
368
- if @file_detector
369
- local_files = keys.first.split("\n").map { |key| @file_detector.call(Array(key)) }.compact
370
- if local_files.any?
371
- keys = local_files.map { |local_file| upload(local_file) }
372
- keys = keys.join("\n")
373
- end
374
- end
375
-
376
- execute :send_keys_to_element, {id: element}, {value: Array(keys)}
377
- end
378
-
379
- def upload(local_file)
380
- unless File.file?(local_file)
381
- WebDriver.logger.debug("File detector only works with files. #{local_file.inspect} isn`t a file!")
382
- raise Error::WebDriverError, "You are trying to work with something that isn't a file."
383
- end
384
-
385
- execute :upload_file, {}, {file: Zipper.zip_file(local_file)}
386
- end
387
-
388
- def clear_element(element)
389
- execute :clear_element, id: element
390
- end
391
-
392
- def submit_element(element)
393
- execute :submit_element, id: element
394
- end
395
-
396
- def drag_element(element, right_by, down_by)
397
- execute :drag_element, {id: element}, {x: right_by, y: down_by}
398
- end
399
-
400
- def touch_single_tap(element)
401
- execute :touch_single_tap, {}, {element: element}
402
- end
403
-
404
- def touch_double_tap(element)
405
- execute :touch_double_tap, {}, {element: element}
406
- end
407
-
408
- def touch_long_press(element)
409
- execute :touch_long_press, {}, {element: element}
410
- end
411
-
412
- def touch_down(x, y)
413
- execute :touch_down, {}, {x: x, y: y}
414
- end
415
-
416
- def touch_up(x, y)
417
- execute :touch_up, {}, {x: x, y: y}
418
- end
419
-
420
- def touch_move(x, y)
421
- execute :touch_move, {}, {x: x, y: y}
422
- end
423
-
424
- def touch_scroll(element, x, y)
425
- if element
426
- execute :touch_scroll, {}, {element: element,
427
- xoffset: x,
428
- yoffset: y}
429
- else
430
- execute :touch_scroll, {}, {xoffset: x, yoffset: y}
431
- end
432
- end
433
-
434
- def touch_flick(xspeed, yspeed)
435
- execute :touch_flick, {}, {xspeed: xspeed, yspeed: yspeed}
436
- end
437
-
438
- def touch_element_flick(element, right_by, down_by, speed)
439
- execute :touch_flick, {}, {element: element,
440
- xoffset: right_by,
441
- yoffset: down_by,
442
- speed: speed}
443
- end
444
-
445
- def screen_orientation=(orientation)
446
- execute :set_screen_orientation, {}, {orientation: orientation}
447
- end
448
-
449
- def screen_orientation
450
- execute :get_screen_orientation
451
- end
452
-
453
- #
454
- # logs
455
- #
456
-
457
- def available_log_types
458
- types = execute :get_available_log_types
459
- Array(types).map(&:to_sym)
460
- end
461
-
462
- def log(type)
463
- data = execute :get_log, {}, {type: type.to_s}
464
-
465
- Array(data).map do |l|
466
- begin
467
- LogEntry.new l.fetch('level', 'UNKNOWN'), l.fetch('timestamp'), l.fetch('message')
468
- rescue KeyError
469
- next
470
- end
471
- end
472
- end
473
-
474
- #
475
- # element properties
476
- #
477
-
478
- def element_tag_name(element)
479
- execute :get_element_tag_name, id: element
480
- end
481
-
482
- def element_attribute(element, name)
483
- execute :get_element_attribute, id: element.ref, name: name
484
- end
485
-
486
- # Backwards compatibility for w3c
487
- def element_property(element, name)
488
- execute_script 'return arguments[0][arguments[1]]', element, name
489
- end
490
-
491
- def element_value(element)
492
- execute :get_element_value, id: element
493
- end
494
-
495
- def element_text(element)
496
- execute :get_element_text, id: element
497
- end
498
-
499
- def element_location(element)
500
- data = execute :get_element_location, id: element
501
-
502
- Point.new data['x'], data['y']
503
- end
504
-
505
- def element_rect(element)
506
- loc = execute :get_element_location, id: element
507
- size = execute :get_element_size, id: element
508
-
509
- Rectangle.new loc['x'], loc['y'], size['width'], size['height']
510
- end
511
-
512
- def element_location_once_scrolled_into_view(element)
513
- data = execute :get_element_location_once_scrolled_into_view, id: element
514
-
515
- Point.new data['x'], data['y']
516
- end
517
-
518
- def element_size(element)
519
- data = execute :get_element_size, id: element
520
-
521
- Dimension.new data['width'], data['height']
522
- end
523
-
524
- def element_enabled?(element)
525
- execute :is_element_enabled, id: element
526
- end
527
-
528
- def element_selected?(element)
529
- execute :is_element_selected, id: element
530
- end
531
-
532
- def element_displayed?(element)
533
- execute :is_element_displayed, id: element.ref
534
- end
535
-
536
- def element_value_of_css_property(element, prop)
537
- execute :get_element_value_of_css_property, id: element, property_name: prop
538
- end
539
-
540
- #
541
- # finding elements
542
- #
543
-
544
- def active_element
545
- Element.new self, element_id_from(execute(:get_active_element))
546
- end
547
-
548
- alias_method :switch_to_active_element, :active_element
549
-
550
- def find_element_by(how, what, parent = nil)
551
- id = if parent
552
- execute :find_child_element, {id: parent}, {using: how, value: what}
553
- else
554
- execute :find_element, {}, {using: how, value: what}
555
- end
556
-
557
- Element.new self, element_id_from(id)
558
- end
559
-
560
- def find_elements_by(how, what, parent = nil)
561
- ids = if parent
562
- execute :find_child_elements, {id: parent}, {using: how, value: what}
563
- else
564
- execute :find_elements, {}, {using: how, value: what}
565
- end
566
- # see https://github.com/SeleniumHQ/selenium/issues/4555
567
- ids ||= []
568
-
569
- ids.map { |id| Element.new self, element_id_from(id) }
570
- end
571
-
572
- private
573
-
574
- def assert_javascript_enabled
575
- return if capabilities.javascript_enabled?
576
-
577
- raise Error::UnsupportedOperationError, 'underlying webdriver instance does not support javascript'
578
- end
579
-
580
- #
581
- # executes a command on the remote server.
582
- #
583
- # Returns the 'value' of the returned payload
584
- #
585
-
586
- def execute(*args)
587
- super['value']
588
- end
589
-
590
- end # Bridge
591
- end # OSS
592
- end # Remote
593
- end # WebDriver
594
- end # Selenium