selenium-webdriver 4.0.0.beta4 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +70 -0
  3. data/README.md +1 -1
  4. data/lib/selenium/webdriver/atoms/getAttribute.js +25 -25
  5. data/lib/selenium/webdriver/chrome/driver.rb +4 -0
  6. data/lib/selenium/webdriver/chrome/features.rb +44 -4
  7. data/lib/selenium/webdriver/chrome/options.rb +24 -1
  8. data/lib/selenium/webdriver/common/driver.rb +5 -1
  9. data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +51 -0
  10. data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +77 -0
  11. data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +45 -0
  12. data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +38 -0
  13. data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +1 -6
  14. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +17 -0
  15. data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +87 -18
  16. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +11 -11
  17. data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +77 -0
  18. data/lib/selenium/webdriver/common/driver_extensions/prints_page.rb +1 -1
  19. data/lib/selenium/webdriver/common/element.rb +17 -8
  20. data/lib/selenium/webdriver/common/error.rb +12 -0
  21. data/lib/selenium/webdriver/common/log_entry.rb +2 -2
  22. data/lib/selenium/webdriver/common/manager.rb +3 -13
  23. data/lib/selenium/webdriver/common/options.rb +13 -5
  24. data/lib/selenium/webdriver/common/shadow_root.rb +87 -0
  25. data/lib/selenium/webdriver/common/socket_poller.rb +30 -19
  26. data/lib/selenium/webdriver/common/target_locator.rb +28 -0
  27. data/lib/selenium/webdriver/common/timeouts.rb +31 -4
  28. data/lib/selenium/webdriver/common/window.rb +0 -4
  29. data/lib/selenium/webdriver/common.rb +6 -0
  30. data/lib/selenium/webdriver/devtools/pinned_script.rb +59 -0
  31. data/lib/selenium/webdriver/devtools/request.rb +27 -17
  32. data/lib/selenium/webdriver/devtools/response.rb +66 -0
  33. data/lib/selenium/webdriver/devtools.rb +50 -12
  34. data/lib/selenium/webdriver/edge/features.rb +5 -0
  35. data/lib/selenium/webdriver/firefox/driver.rb +5 -0
  36. data/lib/selenium/webdriver/firefox/features.rb +14 -0
  37. data/lib/selenium/webdriver/firefox/options.rb +28 -1
  38. data/lib/selenium/webdriver/firefox.rb +0 -1
  39. data/lib/selenium/webdriver/ie/options.rb +3 -1
  40. data/lib/selenium/webdriver/ie/service.rb +1 -1
  41. data/lib/selenium/webdriver/remote/bridge.rb +39 -23
  42. data/lib/selenium/webdriver/remote/capabilities.rb +3 -2
  43. data/lib/selenium/webdriver/remote/commands.rb +4 -0
  44. data/lib/selenium/webdriver/remote/driver.rb +3 -1
  45. data/lib/selenium/webdriver/remote.rb +1 -1
  46. data/lib/selenium/webdriver/safari/driver.rb +1 -1
  47. data/lib/selenium/webdriver/safari/options.rb +7 -0
  48. data/lib/selenium/webdriver/support/event_firing_bridge.rb +2 -2
  49. data/lib/selenium/webdriver/version.rb +1 -1
  50. data/lib/selenium/webdriver.rb +1 -0
  51. data/selenium-webdriver.gemspec +3 -2
  52. metadata +31 -3
@@ -25,7 +25,7 @@ module Selenium
25
25
 
26
26
  PORT = 4444
27
27
 
28
- attr_accessor :context, :http, :file_detector
28
+ attr_accessor :http, :file_detector
29
29
  attr_reader :capabilities
30
30
 
31
31
  #
@@ -93,17 +93,16 @@ module Selenium
93
93
  execute :get, {}, {url: url}
94
94
  end
95
95
 
96
- def implicit_wait_timeout=(milliseconds)
97
- timeout('implicit', milliseconds)
98
- end
96
+ #
97
+ # timeouts
98
+ #
99
99
 
100
- def script_timeout=(milliseconds)
101
- timeout('script', milliseconds)
100
+ def timeouts
101
+ execute :get_timeouts, {}
102
102
  end
103
103
 
104
- def timeout(type, milliseconds)
105
- type = 'pageLoad' if type == 'page load'
106
- execute :set_timeout, {}, {type => milliseconds}
104
+ def timeouts=(timeouts)
105
+ execute :set_timeout, {}, timeouts
107
106
  end
108
107
 
109
108
  #
@@ -269,7 +268,7 @@ module Selenium
269
268
  end
270
269
 
271
270
  def element_screenshot(element)
272
- execute :take_element_screenshot, id: element.ref
271
+ execute :take_element_screenshot, id: element
273
272
  end
274
273
 
275
274
  #
@@ -431,7 +430,7 @@ module Selenium
431
430
  end
432
431
 
433
432
  def submit_element(element)
434
- form = find_element_by('xpath', "./ancestor-or-self::form", element)
433
+ form = find_element_by('xpath', "./ancestor-or-self::form", [:element, element])
435
434
  execute_script("var e = arguments[0].ownerDocument.createEvent('Event');" \
436
435
  "e.initEvent('submit', true, true);" \
437
436
  'if (arguments[0].dispatchEvent(e)) { arguments[0].submit() }', form.as_json)
@@ -451,19 +450,19 @@ module Selenium
451
450
  end
452
451
 
453
452
  def element_dom_attribute(element, name)
454
- execute :get_element_attribute, id: element.ref, name: name
453
+ execute :get_element_attribute, id: element, name: name
455
454
  end
456
455
 
457
456
  def element_property(element, name)
458
- execute :get_element_property, id: element.ref, name: name
457
+ execute :get_element_property, id: element, name: name
459
458
  end
460
459
 
461
460
  def element_aria_role(element)
462
- execute :get_element_aria_role, id: element.ref
461
+ execute :get_element_aria_role, id: element
463
462
  end
464
463
 
465
464
  def element_aria_label(element)
466
- execute :get_element_aria_label, id: element.ref
465
+ execute :get_element_aria_label, id: element
467
466
  end
468
467
 
469
468
  def element_value(element)
@@ -524,13 +523,17 @@ module Selenium
524
523
 
525
524
  alias_method :switch_to_active_element, :active_element
526
525
 
527
- def find_element_by(how, what, parent = nil)
526
+ def find_element_by(how, what, parent_ref = [])
528
527
  how, what = convert_locator(how, what)
529
528
 
530
529
  return execute_atom(:findElements, Support::RelativeLocator.new(what).as_json).first if how == 'relative'
531
530
 
532
- id = if parent
533
- execute :find_child_element, {id: parent}, {using: how, value: what.to_s}
531
+ parent_type, parent_id = parent_ref
532
+ id = case parent_type
533
+ when :element
534
+ execute :find_child_element, {id: parent_id}, {using: how, value: what.to_s}
535
+ when :shadow_root
536
+ execute :find_shadow_child_element, {id: parent_id}, {using: how, value: what.to_s}
534
537
  else
535
538
  execute :find_element, {}, {using: how, value: what.to_s}
536
539
  end
@@ -538,13 +541,17 @@ module Selenium
538
541
  Element.new self, element_id_from(id)
539
542
  end
540
543
 
541
- def find_elements_by(how, what, parent = nil)
544
+ def find_elements_by(how, what, parent_ref = [])
542
545
  how, what = convert_locator(how, what)
543
546
 
544
547
  return execute_atom :findElements, Support::RelativeLocator.new(what).as_json if how == 'relative'
545
548
 
546
- ids = if parent
547
- execute :find_child_elements, {id: parent}, {using: how, value: what.to_s}
549
+ parent_type, parent_id = parent_ref
550
+ ids = case parent_type
551
+ when :element
552
+ execute :find_child_elements, {id: parent_id}, {using: how, value: what.to_s}
553
+ when :shadow_root
554
+ execute :find_shadow_child_elements, {id: parent_id}, {using: how, value: what.to_s}
548
555
  else
549
556
  execute :find_elements, {}, {using: how, value: what.to_s}
550
557
  end
@@ -552,6 +559,11 @@ module Selenium
552
559
  ids.map { |id| Element.new self, element_id_from(id) }
553
560
  end
554
561
 
562
+ def shadow_root(element)
563
+ id = execute :get_element_shadow_root, id: element
564
+ ShadowRoot.new self, shadow_root_id_from(id)
565
+ end
566
+
555
567
  private
556
568
 
557
569
  #
@@ -599,7 +611,11 @@ module Selenium
599
611
  end
600
612
 
601
613
  def element_id_from(id)
602
- id['ELEMENT'] || id['element-6066-11e4-a52e-4f735466cecf']
614
+ id['ELEMENT'] || id[Element::ELEMENT_KEY]
615
+ end
616
+
617
+ def shadow_root_id_from(id)
618
+ id[ShadowRoot::ROOT_KEY]
603
619
  end
604
620
 
605
621
  def prepare_capabilities_payload(capabilities)
@@ -641,7 +657,7 @@ module Selenium
641
657
  # @see https://mathiasbynens.be/notes/css-escapes
642
658
  def escape_css(string)
643
659
  string = string.gsub(ESCAPE_CSS_REGEXP) { |match| "\\#{match}" }
644
- string = "\\#{UNICODE_CODE_POINT + Integer(string[0])} #{string[1..-1]}" if string[0]&.match?(/[[:digit:]]/)
660
+ string = "\\#{UNICODE_CODE_POINT + Integer(string[0])} #{string[1..]}" if string[0]&.match?(/[[:digit:]]/)
645
661
 
646
662
  string
647
663
  end
@@ -39,6 +39,7 @@ module Selenium
39
39
  :timeouts,
40
40
  :unhandled_prompt_behavior,
41
41
  :strict_file_interactability,
42
+ :web_socket_url,
42
43
 
43
44
  # remote-specific (webdriver.remote.sessionid)
44
45
  :remote_session_id
@@ -46,7 +47,7 @@ module Selenium
46
47
 
47
48
  (KNOWN - %i[proxy timeouts]).each do |key|
48
49
  define_method key do
49
- @capabilities.fetch(key)
50
+ @capabilities[key]
50
51
  end
51
52
 
52
53
  define_method "#{key}=" do |value|
@@ -202,7 +203,7 @@ module Selenium
202
203
  end
203
204
 
204
205
  def proxy
205
- @capabilities.fetch(:proxy)
206
+ @capabilities[:proxy]
206
207
  end
207
208
 
208
209
  def proxy=(proxy)
@@ -77,7 +77,10 @@ module Selenium
77
77
  find_elements: [:post, 'session/:session_id/elements'],
78
78
  find_child_element: [:post, 'session/:session_id/element/:id/element'],
79
79
  find_child_elements: [:post, 'session/:session_id/element/:id/elements'],
80
+ find_shadow_child_element: [:post, 'session/:session_id/shadow/:id/element'],
81
+ find_shadow_child_elements: [:post, 'session/:session_id/shadow/:id/elements'],
80
82
  get_active_element: [:get, 'session/:session_id/element/active'],
83
+ get_element_shadow_root: [:get, 'session/:session_id/element/:id/shadow'],
81
84
  is_element_selected: [:get, 'session/:session_id/element/:id/selected'],
82
85
  get_element_attribute: [:get, 'session/:session_id/element/:id/attribute/:name'],
83
86
  get_element_property: [:get, 'session/:session_id/element/:id/property/:name'],
@@ -111,6 +114,7 @@ module Selenium
111
114
  # timeouts
112
115
  #
113
116
 
117
+ get_timeouts: [:get, 'session/:session_id/timeouts'],
114
118
  set_timeout: [:post, 'session/:session_id/timeouts'],
115
119
 
116
120
  #
@@ -42,6 +42,7 @@ module Selenium
42
42
  end
43
43
  opts[:url] ||= "http://#{Platform.localhost}:4444/wd/hub"
44
44
  super
45
+ @bridge.file_detector = ->((filename, *)) { File.exist?(filename) && filename.to_s }
45
46
  end
46
47
 
47
48
  private
@@ -51,7 +52,8 @@ module Selenium
51
52
  end
52
53
 
53
54
  def devtools_version
54
- capabilities['se:cdpVersion'].split('.').first
55
+ capabilities['se:cdpVersion']&.split('.')&.first ||
56
+ raise(Error::WebDriverError, "DevTools is not supported by the Remote Server")
55
57
  end
56
58
  end # Driver
57
59
  end # Remote
@@ -18,6 +18,7 @@
18
18
  # under the License.
19
19
 
20
20
  require 'uri'
21
+ require 'selenium/webdriver/remote/server_error'
21
22
 
22
23
  module Selenium
23
24
  module WebDriver
@@ -25,7 +26,6 @@ module Selenium
25
26
  autoload :Bridge, 'selenium/webdriver/remote/bridge'
26
27
  autoload :Driver, 'selenium/webdriver/remote/driver'
27
28
  autoload :Response, 'selenium/webdriver/remote/response'
28
- autoload :ServerError, 'selenium/webdriver/remote/server_error'
29
29
  autoload :Capabilities, 'selenium/webdriver/remote/capabilities'
30
30
  autoload :COMMANDS, 'selenium/webdriver/remote/commands'
31
31
  module Http
@@ -28,7 +28,7 @@ module Selenium
28
28
 
29
29
  class Driver < WebDriver::Driver
30
30
  EXTENSIONS = [DriverExtensions::HasDebugger,
31
- DriverExtensions::HasPermissions,
31
+ DriverExtensions::HasApplePermissions,
32
32
  DriverExtensions::HasWebStorage].freeze
33
33
 
34
34
  def browser
@@ -28,6 +28,13 @@ module Selenium
28
28
  automatic_profiling: 'safari:automaticProfiling'}.freeze
29
29
  BROWSER = 'safari'
30
30
 
31
+ def add_option(name, value = nil)
32
+ key = name.is_a?(Hash) ? name.keys.first : name
33
+ raise ArgumentError, 'Safari does not support options that are not namespaced' unless key.to_s.include?(':')
34
+
35
+ super
36
+ end
37
+
31
38
  end # Options
32
39
  end # Safari
33
40
  end # WebDriver
@@ -76,7 +76,7 @@ module Selenium
76
76
  @delegate.find_element_by how, what, parent
77
77
  end
78
78
 
79
- Element.new self, e.ref
79
+ Element.new self, e.ref.last
80
80
  end
81
81
 
82
82
  def find_elements_by(how, what, parent = nil)
@@ -84,7 +84,7 @@ module Selenium
84
84
  @delegate.find_elements_by(how, what, parent)
85
85
  end
86
86
 
87
- es.map { |e| Element.new self, e.ref }
87
+ es.map { |e| Element.new self, e.ref.last }
88
88
  end
89
89
 
90
90
  def execute_script(script, *args)
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
- VERSION = '4.0.0.beta4'
22
+ VERSION = '4.0.0'
23
23
  end # WebDriver
24
24
  end # Selenium
@@ -23,6 +23,7 @@ require 'fileutils'
23
23
  require 'date'
24
24
  require 'json'
25
25
  require 'set'
26
+ require 'uri'
26
27
 
27
28
  require 'selenium/webdriver/atoms'
28
29
  require 'selenium/webdriver/common'
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
28
28
  }
29
29
 
30
30
  s.required_rubygems_version = Gem::Requirement.new('> 1.3.1') if s.respond_to? :required_rubygems_version=
31
- s.required_ruby_version = Gem::Requirement.new('>= 2.5')
31
+ s.required_ruby_version = Gem::Requirement.new('>= 2.6')
32
32
 
33
33
  s.files = [
34
34
  'CHANGES',
@@ -45,11 +45,12 @@ Gem::Specification.new do |s|
45
45
  s.require_paths = ['lib']
46
46
 
47
47
  s.add_runtime_dependency 'childprocess', ['>= 0.5', '< 5.0']
48
- s.add_runtime_dependency 'rexml', ['~> 3.2']
48
+ s.add_runtime_dependency 'rexml', ['~> 3.2', '>= 3.2.5']
49
49
  s.add_runtime_dependency 'rubyzip', ['>= 1.2.2']
50
50
 
51
51
  # childprocess requires ffi on windows but doesn't declare it in its dependencies
52
52
  s.add_development_dependency 'ffi'
53
+ s.add_development_dependency 'pry', ['~> 0.14']
53
54
  s.add_development_dependency 'rack', ['~> 2.0']
54
55
  s.add_development_dependency 'rake'
55
56
  s.add_development_dependency 'rspec', ['~> 3.0']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: selenium-webdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0.beta4
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Rodionov
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2021-06-07 00:00:00.000000000 Z
13
+ date: 2021-10-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: childprocess
@@ -39,6 +39,9 @@ dependencies:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: '3.2'
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 3.2.5
42
45
  type: :runtime
43
46
  prerelease: false
44
47
  version_requirements: !ruby/object:Gem::Requirement
@@ -46,6 +49,9 @@ dependencies:
46
49
  - - "~>"
47
50
  - !ruby/object:Gem::Version
48
51
  version: '3.2'
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 3.2.5
49
55
  - !ruby/object:Gem::Dependency
50
56
  name: rubyzip
51
57
  requirement: !ruby/object:Gem::Requirement
@@ -74,6 +80,20 @@ dependencies:
74
80
  - - ">="
75
81
  - !ruby/object:Gem::Version
76
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.14'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.14'
77
97
  - !ruby/object:Gem::Dependency
78
98
  name: rack
79
99
  requirement: !ruby/object:Gem::Requirement
@@ -238,10 +258,14 @@ files:
238
258
  - lib/selenium/webdriver/common/driver_extensions/downloads_files.rb
239
259
  - lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb
240
260
  - lib/selenium/webdriver/common/driver_extensions/has_addons.rb
261
+ - lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb
241
262
  - lib/selenium/webdriver/common/driver_extensions/has_authentication.rb
263
+ - lib/selenium/webdriver/common/driver_extensions/has_casting.rb
242
264
  - lib/selenium/webdriver/common/driver_extensions/has_cdp.rb
265
+ - lib/selenium/webdriver/common/driver_extensions/has_context.rb
243
266
  - lib/selenium/webdriver/common/driver_extensions/has_debugger.rb
244
267
  - lib/selenium/webdriver/common/driver_extensions/has_devtools.rb
268
+ - lib/selenium/webdriver/common/driver_extensions/has_launching.rb
245
269
  - lib/selenium/webdriver/common/driver_extensions/has_location.rb
246
270
  - lib/selenium/webdriver/common/driver_extensions/has_log_events.rb
247
271
  - lib/selenium/webdriver/common/driver_extensions/has_logs.rb
@@ -249,6 +273,7 @@ files:
249
273
  - lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb
250
274
  - lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb
251
275
  - lib/selenium/webdriver/common/driver_extensions/has_permissions.rb
276
+ - lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb
252
277
  - lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb
253
278
  - lib/selenium/webdriver/common/driver_extensions/has_session_id.rb
254
279
  - lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb
@@ -282,6 +307,7 @@ files:
282
307
  - lib/selenium/webdriver/common/search_context.rb
283
308
  - lib/selenium/webdriver/common/service.rb
284
309
  - lib/selenium/webdriver/common/service_manager.rb
310
+ - lib/selenium/webdriver/common/shadow_root.rb
285
311
  - lib/selenium/webdriver/common/socket_lock.rb
286
312
  - lib/selenium/webdriver/common/socket_poller.rb
287
313
  - lib/selenium/webdriver/common/takes_screenshot.rb
@@ -294,7 +320,9 @@ files:
294
320
  - lib/selenium/webdriver/devtools/console_event.rb
295
321
  - lib/selenium/webdriver/devtools/exception_event.rb
296
322
  - lib/selenium/webdriver/devtools/mutation_event.rb
323
+ - lib/selenium/webdriver/devtools/pinned_script.rb
297
324
  - lib/selenium/webdriver/devtools/request.rb
325
+ - lib/selenium/webdriver/devtools/response.rb
298
326
  - lib/selenium/webdriver/edge.rb
299
327
  - lib/selenium/webdriver/edge/driver.rb
300
328
  - lib/selenium/webdriver/edge/features.rb
@@ -358,7 +386,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
358
386
  requirements:
359
387
  - - ">="
360
388
  - !ruby/object:Gem::Version
361
- version: '2.5'
389
+ version: '2.6'
362
390
  required_rubygems_version: !ruby/object:Gem::Requirement
363
391
  requirements:
364
392
  - - ">"