selenium-webdriver 3.142.7 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES +432 -5
  3. data/Gemfile +3 -1
  4. data/LICENSE +1 -1
  5. data/NOTICE +2 -0
  6. data/README.md +4 -5
  7. data/lib/selenium/server.rb +75 -64
  8. data/lib/selenium/webdriver/atoms/findElements.js +122 -0
  9. data/lib/selenium/webdriver/atoms/getAttribute.js +100 -7
  10. data/lib/selenium/webdriver/atoms/isDisplayed.js +76 -78
  11. data/lib/selenium/webdriver/atoms/mutationListener.js +55 -0
  12. data/lib/selenium/webdriver/bidi/session.rb +38 -0
  13. data/lib/selenium/webdriver/bidi.rb +55 -0
  14. data/lib/selenium/webdriver/chrome/driver.rb +26 -83
  15. data/lib/selenium/webdriver/chrome/{bridge.rb → features.rb} +55 -12
  16. data/lib/selenium/webdriver/chrome/options.rb +138 -67
  17. data/lib/selenium/webdriver/chrome/profile.rb +6 -3
  18. data/lib/selenium/webdriver/chrome/service.rb +8 -15
  19. data/lib/selenium/webdriver/chrome.rb +5 -18
  20. data/lib/selenium/webdriver/common/action_builder.rb +171 -236
  21. data/lib/selenium/webdriver/common/driver.rb +76 -29
  22. data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +43 -0
  23. data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +51 -0
  24. data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +89 -0
  25. data/lib/selenium/webdriver/common/driver_extensions/{has_touch_screen.rb → has_bidi.rb} +10 -8
  26. data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +87 -0
  27. data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +38 -0
  28. data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +44 -0
  29. data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +43 -0
  30. data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +38 -0
  31. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +5 -8
  32. data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +144 -0
  33. data/lib/selenium/webdriver/common/driver_extensions/{has_remote_status.rb → has_logs.rb} +4 -4
  34. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +17 -0
  35. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +6 -27
  36. data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +136 -0
  37. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +11 -11
  38. data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +77 -0
  39. data/lib/selenium/webdriver/common/driver_extensions/{rotatable.rb → prints_page.rb} +18 -20
  40. data/lib/selenium/webdriver/common/element.rb +83 -23
  41. data/lib/selenium/webdriver/common/error.rb +32 -196
  42. data/lib/selenium/webdriver/common/interactions/input_device.rb +10 -4
  43. data/lib/selenium/webdriver/common/interactions/interaction.rb +12 -22
  44. data/lib/selenium/webdriver/common/interactions/interactions.rb +24 -4
  45. data/lib/selenium/webdriver/common/interactions/key_actions.rb +10 -6
  46. data/lib/selenium/webdriver/common/interactions/key_input.rb +11 -27
  47. data/lib/selenium/webdriver/common/interactions/none_input.rb +10 -8
  48. data/lib/selenium/webdriver/common/interactions/pause.rb +49 -0
  49. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +68 -78
  50. data/lib/selenium/webdriver/common/interactions/pointer_cancel.rb +45 -0
  51. data/lib/selenium/webdriver/common/interactions/pointer_event_properties.rb +63 -0
  52. data/lib/selenium/webdriver/common/interactions/pointer_input.rb +15 -84
  53. data/lib/selenium/webdriver/common/interactions/pointer_move.rb +60 -0
  54. data/lib/selenium/webdriver/common/interactions/pointer_press.rb +85 -0
  55. data/lib/selenium/webdriver/common/interactions/scroll.rb +57 -0
  56. data/lib/selenium/webdriver/common/interactions/scroll_origin.rb +48 -0
  57. data/lib/selenium/webdriver/common/interactions/typing_interaction.rb +54 -0
  58. data/lib/selenium/webdriver/common/interactions/wheel_actions.rb +113 -0
  59. data/lib/selenium/webdriver/common/{w3c_manager.rb → interactions/wheel_input.rb} +14 -17
  60. data/lib/selenium/webdriver/common/keys.rb +1 -0
  61. data/lib/selenium/webdriver/common/log_entry.rb +2 -2
  62. data/lib/selenium/webdriver/common/logger.rb +50 -15
  63. data/lib/selenium/webdriver/common/manager.rb +11 -38
  64. data/lib/selenium/webdriver/common/options.rb +147 -23
  65. data/lib/selenium/webdriver/common/platform.rb +10 -5
  66. data/lib/selenium/webdriver/common/port_prober.rb +4 -6
  67. data/lib/selenium/webdriver/common/profile_helper.rb +11 -9
  68. data/lib/selenium/webdriver/common/proxy.rb +6 -3
  69. data/lib/selenium/webdriver/common/search_context.rb +7 -9
  70. data/lib/selenium/webdriver/common/service.rb +17 -125
  71. data/lib/selenium/webdriver/common/service_manager.rb +150 -0
  72. data/lib/selenium/webdriver/common/shadow_root.rb +87 -0
  73. data/lib/selenium/webdriver/common/socket_lock.rb +2 -2
  74. data/lib/selenium/webdriver/common/socket_poller.rb +3 -3
  75. data/lib/selenium/webdriver/common/takes_screenshot.rb +66 -0
  76. data/lib/selenium/webdriver/common/target_locator.rb +32 -4
  77. data/lib/selenium/webdriver/common/timeouts.rb +31 -4
  78. data/lib/selenium/webdriver/common/wait.rb +1 -1
  79. data/lib/selenium/webdriver/common/websocket_connection.rb +149 -0
  80. data/lib/selenium/webdriver/common/window.rb +0 -4
  81. data/lib/selenium/webdriver/common/zipper.rb +3 -9
  82. data/lib/selenium/webdriver/common.rb +35 -18
  83. data/lib/selenium/webdriver/devtools/console_event.rb +38 -0
  84. data/lib/selenium/webdriver/devtools/exception_event.rb +36 -0
  85. data/lib/selenium/webdriver/devtools/mutation_event.rb +37 -0
  86. data/lib/selenium/webdriver/devtools/pinned_script.rb +59 -0
  87. data/lib/selenium/webdriver/devtools/request.rb +67 -0
  88. data/lib/selenium/webdriver/devtools/response.rb +66 -0
  89. data/lib/selenium/webdriver/devtools.rb +86 -0
  90. data/lib/selenium/webdriver/edge/driver.rb +7 -29
  91. data/lib/selenium/webdriver/edge/features.rb +45 -0
  92. data/lib/selenium/webdriver/edge/options.rb +11 -48
  93. data/lib/selenium/webdriver/edge/profile.rb +33 -0
  94. data/lib/selenium/webdriver/edge/service.rb +10 -26
  95. data/lib/selenium/webdriver/edge.rb +11 -14
  96. data/lib/selenium/webdriver/firefox/driver.rb +32 -19
  97. data/lib/selenium/webdriver/firefox/extension.rb +8 -0
  98. data/lib/selenium/webdriver/firefox/features.rb +63 -0
  99. data/lib/selenium/webdriver/firefox/options.rb +73 -50
  100. data/lib/selenium/webdriver/firefox/profile.rb +16 -70
  101. data/lib/selenium/webdriver/firefox/service.rb +5 -9
  102. data/lib/selenium/webdriver/firefox/util.rb +1 -1
  103. data/lib/selenium/webdriver/firefox.rb +17 -28
  104. data/lib/selenium/webdriver/ie/driver.rb +1 -47
  105. data/lib/selenium/webdriver/ie/options.rb +15 -46
  106. data/lib/selenium/webdriver/ie/service.rb +13 -15
  107. data/lib/selenium/webdriver/ie.rb +3 -16
  108. data/lib/selenium/webdriver/remote/bridge.rb +563 -86
  109. data/lib/selenium/webdriver/remote/capabilities.rb +159 -123
  110. data/lib/selenium/webdriver/remote/commands.rb +158 -0
  111. data/lib/selenium/webdriver/remote/driver.rb +22 -13
  112. data/lib/selenium/webdriver/remote/http/common.rb +0 -5
  113. data/lib/selenium/webdriver/remote/http/default.rb +22 -31
  114. data/lib/selenium/webdriver/remote/response.rb +18 -49
  115. data/lib/selenium/webdriver/remote.rb +15 -12
  116. data/lib/selenium/webdriver/safari/driver.rb +3 -31
  117. data/lib/selenium/webdriver/safari/{bridge.rb → features.rb} +3 -3
  118. data/lib/selenium/webdriver/safari/options.rb +10 -29
  119. data/lib/selenium/webdriver/safari/service.rb +4 -8
  120. data/lib/selenium/webdriver/safari.rb +13 -19
  121. data/lib/selenium/webdriver/support/block_event_listener.rb +1 -1
  122. data/lib/selenium/webdriver/support/cdp/domain.rb.erb +63 -0
  123. data/lib/selenium/webdriver/support/cdp_client_generator.rb +108 -0
  124. data/lib/selenium/webdriver/support/color.rb +9 -9
  125. data/lib/selenium/webdriver/support/event_firing_bridge.rb +4 -4
  126. data/lib/selenium/webdriver/support/guards/guard.rb +89 -0
  127. data/lib/selenium/webdriver/{firefox/marionette/bridge.rb → support/guards/guard_condition.rb} +22 -19
  128. data/lib/selenium/webdriver/support/guards.rb +95 -0
  129. data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
  130. data/lib/selenium/webdriver/support/select.rb +3 -3
  131. data/lib/selenium/webdriver/support.rb +1 -0
  132. data/lib/selenium/webdriver/version.rb +1 -1
  133. data/lib/selenium/webdriver.rb +14 -13
  134. data/selenium-webdriver.gemspec +32 -13
  135. metadata +176 -69
  136. data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
  137. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +0 -64
  138. data/lib/selenium/webdriver/common/keyboard.rb +0 -70
  139. data/lib/selenium/webdriver/common/mouse.rb +0 -89
  140. data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -78
  141. data/lib/selenium/webdriver/common/touch_screen.rb +0 -123
  142. data/lib/selenium/webdriver/common/w3c_action_builder.rb +0 -212
  143. data/lib/selenium/webdriver/edge/bridge.rb +0 -76
  144. data/lib/selenium/webdriver/firefox/binary.rb +0 -187
  145. data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
  146. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  147. data/lib/selenium/webdriver/firefox/launcher.rb +0 -111
  148. data/lib/selenium/webdriver/firefox/legacy/driver.rb +0 -83
  149. data/lib/selenium/webdriver/firefox/marionette/driver.rb +0 -90
  150. data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
  151. data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
  152. data/lib/selenium/webdriver/remote/http/persistent.rb +0 -60
  153. data/lib/selenium/webdriver/remote/oss/bridge.rb +0 -594
  154. data/lib/selenium/webdriver/remote/oss/commands.rb +0 -223
  155. data/lib/selenium/webdriver/remote/w3c/bridge.rb +0 -605
  156. data/lib/selenium/webdriver/remote/w3c/capabilities.rb +0 -310
  157. data/lib/selenium/webdriver/remote/w3c/commands.rb +0 -157
@@ -72,7 +72,7 @@ module Selenium
72
72
  end
73
73
  end
74
74
 
75
- def self.from_hsl(h, s, l, a) # rubocop:disable Naming/UncommunicativeMethodParamName
75
+ def self.from_hsl(h, s, l, a) # rubocop:disable Naming/MethodParameterName
76
76
  h = Float(h) / 360
77
77
  s = Float(s) / 100
78
78
  l = Float(l) / 100
@@ -83,12 +83,12 @@ module Selenium
83
83
  g = r
84
84
  b = r
85
85
  else
86
- luminocity2 = l < 0.5 ? l * (1 + s) : l + s - l * s
87
- luminocity1 = 2 * l - luminocity2
86
+ luminocity2 = l < 0.5 ? l * (1 + s) : l + s - (l * s)
87
+ luminocity1 = (2 * l) - luminocity2
88
88
 
89
- r = hue_to_rgb(luminocity1, luminocity2, h + 1.0 / 3.0)
89
+ r = hue_to_rgb(luminocity1, luminocity2, h + (1.0 / 3.0))
90
90
  g = hue_to_rgb(luminocity1, luminocity2, h)
91
- b = hue_to_rgb(luminocity1, luminocity2, h - 1.0 / 3.0)
91
+ b = hue_to_rgb(luminocity1, luminocity2, h - (1.0 / 3.0))
92
92
  end
93
93
 
94
94
  new (r * 255).round, (g * 255).round, (b * 255).round, a
@@ -99,11 +99,11 @@ module Selenium
99
99
  hue -= 1 if hue > 1.0
100
100
 
101
101
  if hue < 1.0 / 6.0
102
- (lum1 + (lum2 - lum1) * 6.0 * hue)
102
+ (lum1 + ((lum2 - lum1) * 6.0 * hue))
103
103
  elsif hue < 1.0 / 2.0
104
104
  lum2
105
105
  elsif hue < 2.0 / 3.0
106
- lum1 + (lum2 - lum1) * ((2.0 / 3.0) - hue) * 6.0
106
+ lum1 + ((lum2 - lum1) * ((2.0 / 3.0) - hue) * 6.0)
107
107
  else
108
108
  lum1
109
109
  end
@@ -125,7 +125,7 @@ module Selenium
125
125
  alias_method :eql?, :==
126
126
 
127
127
  def hash
128
- [red, green, blue, alpha].hash ^ self.class.hash
128
+ [red, green, blue, alpha, self.class].hash
129
129
  end
130
130
 
131
131
  def rgb
@@ -138,7 +138,7 @@ module Selenium
138
138
  end
139
139
 
140
140
  def hex
141
- format '#%02x%02x%02x', red, green, blue
141
+ format '#%<red>02x%<green>02x%<blue>02x', red: red, green: green, blue: blue
142
142
  end
143
143
  end # Color
144
144
  end # Support
@@ -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)
@@ -109,7 +109,7 @@ module Selenium
109
109
  end
110
110
 
111
111
  def driver
112
- @driver ||= Driver.new(self)
112
+ @driver ||= Driver.new(bridge: self)
113
113
  end
114
114
 
115
115
  def dispatch(name, *args)
@@ -120,7 +120,7 @@ module Selenium
120
120
  returned
121
121
  end
122
122
 
123
- def method_missing(meth, *args, &blk) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
123
+ def method_missing(meth, *args, &blk) # rubocop:disable Style/MissingRespondToMissing
124
124
  @delegate.__send__(meth, *args, &blk)
125
125
  end
126
126
  end # EventFiringBridge
@@ -0,0 +1,89 @@
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 Support
23
+ class Guards
24
+
25
+ #
26
+ # Guard derived from RSpec example metadata.
27
+ # @api private
28
+ #
29
+
30
+ class Guard
31
+
32
+ attr_reader :guarded, :type, :messages, :reason
33
+
34
+ def initialize(guarded, type, guards = nil)
35
+ @guarded = guarded
36
+ @tracker = guards&.bug_tracker || ''
37
+ @messages = guards&.messages || {}
38
+ @messages[:unknown] = 'TODO: Investigate why this is failing and file a bug report'
39
+ @type = type
40
+
41
+ @reason = @guarded.delete(:reason)
42
+ end
43
+
44
+ def message
45
+ details = case @reason
46
+ when Integer
47
+ "Bug Filed: #{@tracker}/#{@reason}"
48
+ when Symbol
49
+ @messages[@reason]
50
+ when String
51
+ @reason
52
+ else
53
+ 'no reason given'
54
+ end
55
+
56
+ case @type
57
+ when :exclude
58
+ "Test not guarded because it breaks test run; #{details}"
59
+ when :exclusive
60
+ "Test does not apply to this configuration; #{details}"
61
+ else
62
+ "Test guarded; #{details}"
63
+ end
64
+ end
65
+
66
+ # Bug is present on all configurations specified
67
+ def except?
68
+ @type == :except
69
+ end
70
+
71
+ # Bug is present on all configurations not specified
72
+ def only?
73
+ @type == :only
74
+ end
75
+
76
+ # Bug is present on all configurations specified, but test can not be run because it breaks other tests
77
+ def exclude?
78
+ @type == :exclude
79
+ end
80
+
81
+ # Test only applies to configurations specified
82
+ def exclusive?
83
+ @type == :exclusive
84
+ end
85
+ end # Guard
86
+ end # Guards
87
+ end # Support
88
+ end # WebDriver
89
+ end # Selenium
@@ -19,31 +19,34 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
- module Firefox
23
- module Marionette
24
- module Bridge
22
+ module Support
23
+ class Guards
25
24
 
26
- COMMANDS = {
27
- install_addon: [:post, 'session/:session_id/moz/addon/install'],
28
- uninstall_addon: [:post, 'session/:session_id/moz/addon/uninstall']
29
- }.freeze
25
+ #
26
+ # Guard derived from RSpec example metadata.
27
+ # @api private
28
+ #
30
29
 
31
- def commands(command)
32
- COMMANDS[command] || super
33
- end
30
+ class GuardCondition
31
+ attr_accessor :name, :execution
34
32
 
35
- def install_addon(path, temporary)
36
- payload = {path: path}
37
- payload[:temporary] = temporary unless temporary.nil?
38
- execute :install_addon, {}, payload
33
+ def initialize(name, condition = nil, &blk)
34
+ @name = name
35
+ @execution = if blk
36
+ proc(&blk)
37
+ else
38
+ proc { |guarded| guarded.include?(condition) }
39
+ end
39
40
  end
40
41
 
41
- def uninstall_addon(id)
42
- execute :uninstall_addon, {}, {id: id}
42
+ def satisfied?(guard)
43
+ list = Array(guard.guarded[@name])
44
+
45
+ list.empty? || @execution.call(list)
43
46
  end
44
47
 
45
- end # Bridge
46
- end # Marionette
47
- end # Firefox
48
+ end # GuardCondition
49
+ end # Guards
50
+ end # Support
48
51
  end # WebDriver
49
52
  end # Selenium
@@ -0,0 +1,95 @@
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
+ require_relative 'guards/guard_condition'
21
+ require_relative 'guards/guard'
22
+
23
+ module Selenium
24
+ module WebDriver
25
+ module Support
26
+ class Guards
27
+ GUARD_TYPES = %i[except only exclude exclusive].freeze
28
+
29
+ attr_reader :messages
30
+ attr_accessor :bug_tracker
31
+
32
+ def initialize(example, bug_tracker: '', conditions: nil)
33
+ @example = example
34
+ @bug_tracker = bug_tracker
35
+ @guard_conditions = conditions || []
36
+ @guards = collect_example_guards
37
+ @messages = {}
38
+ end
39
+
40
+ def add_condition(name, condition = nil, &blk)
41
+ @guard_conditions << GuardCondition.new(name, condition, &blk)
42
+ end
43
+
44
+ def add_message(name, message)
45
+ @messages[name] = message
46
+ end
47
+
48
+ def disposition
49
+ if !skipping_guard.nil?
50
+ [:skip, skipping_guard.message]
51
+ elsif !pending_guard.nil? && ENV.fetch('SKIP_PENDING', nil)
52
+ [:skip, pending_guard.message]
53
+ elsif !pending_guard.nil?
54
+ [:pending, pending_guard.message]
55
+ end
56
+ end
57
+
58
+ def satisfied?(guard)
59
+ @guard_conditions.all? { |condition| condition.satisfied?(guard) }
60
+ end
61
+
62
+ private
63
+
64
+ def collect_example_guards
65
+ guards = []
66
+
67
+ GUARD_TYPES.each do |guard_type|
68
+ example_group = @example.metadata[:example_group]
69
+ example_guards = [@example.metadata[guard_type], example_group[guard_type]]
70
+ while example_group[:parent_example_group]
71
+ example_group = example_group[:parent_example_group]
72
+ example_guards << example_group[guard_type]
73
+ end
74
+
75
+ example_guards.flatten.uniq.compact.each do |example_guard|
76
+ guards << Guard.new(example_guard, guard_type, self)
77
+ end
78
+ end
79
+
80
+ guards
81
+ end
82
+
83
+ def skipping_guard
84
+ @guards.select(&:exclusive?).find { |guard| !satisfied?(guard) } ||
85
+ @guards.select(&:exclude?).find { |guard| satisfied?(guard) }
86
+ end
87
+
88
+ def pending_guard
89
+ @guards.select(&:except?).find { |guard| satisfied?(guard) } ||
90
+ @guards.select(&:only?).find { |guard| !satisfied?(guard) }
91
+ end
92
+ end # Guards
93
+ end # Support
94
+ end # WebDriver
95
+ 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 Support
23
+
24
+ #
25
+ # @api private
26
+ #
27
+
28
+ class RelativeLocator
29
+ KEYS = %w[above below left right near distance].freeze
30
+
31
+ def initialize(locator)
32
+ @filters, @root = locator.partition { |how, _| KEYS.include?(how) }.map(&:to_h)
33
+ end
34
+
35
+ def as_json
36
+ {
37
+ relative: {
38
+ root: @root,
39
+ filters: @filters.map do |kind, filter|
40
+ {
41
+ kind: kind,
42
+ args: [filter]
43
+ }
44
+ end
45
+ }
46
+ }
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -31,7 +31,7 @@ module Selenium
31
31
  raise ArgumentError, "unexpected tag name #{tag_name.inspect}" unless tag_name.casecmp('select').zero?
32
32
 
33
33
  @element = element
34
- @multi = ![nil, 'false'].include?(element.attribute(:multiple))
34
+ @multi = ![nil, 'false'].include?(element.dom_attribute(:multiple))
35
35
  end
36
36
 
37
37
  #
@@ -242,7 +242,7 @@ module Selenium
242
242
  xpath = ".//option[normalize-space(.) = #{Escaper.escape text}]"
243
243
  opts = @element.find_elements(xpath: xpath)
244
244
 
245
- return opts unless opts.empty? && text =~ /\s+/
245
+ return opts unless opts.empty? && /\s+/.match?(text)
246
246
 
247
247
  longest_word = text.split(/\s+/).max_by(&:length)
248
248
  if longest_word.empty?
@@ -258,7 +258,7 @@ module Selenium
258
258
  end
259
259
 
260
260
  def find_by_index(index)
261
- options.select { |option| option.attribute(:index) == index.to_s }
261
+ options.select { |option| option.property(:index) == index }
262
262
  end
263
263
 
264
264
  def find_by_value(value)
@@ -23,3 +23,4 @@ require 'selenium/webdriver/support/block_event_listener'
23
23
  require 'selenium/webdriver/support/escaper'
24
24
  require 'selenium/webdriver/support/select'
25
25
  require 'selenium/webdriver/support/color'
26
+ require 'selenium/webdriver/support/relative_locator'
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
- VERSION = '3.142.7'
22
+ VERSION = '4.3.0'
23
23
  end # WebDriver
24
24
  end # Selenium
@@ -23,9 +23,10 @@ require 'fileutils'
23
23
  require 'date'
24
24
  require 'json'
25
25
  require 'set'
26
+ require 'uri'
26
27
 
27
- require 'selenium/webdriver/common'
28
28
  require 'selenium/webdriver/atoms'
29
+ require 'selenium/webdriver/common'
29
30
  require 'selenium/webdriver/version'
30
31
 
31
32
  module Selenium
@@ -35,14 +36,15 @@ module Selenium
35
36
  Rectangle = Struct.new(:x, :y, :width, :height)
36
37
  Location = Struct.new(:latitude, :longitude, :altitude)
37
38
 
38
- autoload :Chrome, 'selenium/webdriver/chrome'
39
- autoload :Edge, 'selenium/webdriver/edge'
40
- autoload :Firefox, 'selenium/webdriver/firefox'
41
- autoload :IE, 'selenium/webdriver/ie'
42
- autoload :PhantomJS, 'selenium/webdriver/phantomjs'
43
- autoload :Remote, 'selenium/webdriver/remote'
44
- autoload :Safari, 'selenium/webdriver/safari'
45
- autoload :Support, 'selenium/webdriver/support'
39
+ autoload :BiDi, 'selenium/webdriver/bidi'
40
+ autoload :Chrome, 'selenium/webdriver/chrome'
41
+ autoload :DevTools, 'selenium/webdriver/devtools'
42
+ autoload :Edge, 'selenium/webdriver/edge'
43
+ autoload :Firefox, 'selenium/webdriver/firefox'
44
+ autoload :IE, 'selenium/webdriver/ie'
45
+ autoload :Remote, 'selenium/webdriver/remote'
46
+ autoload :Safari, 'selenium/webdriver/safari'
47
+ autoload :Support, 'selenium/webdriver/support'
46
48
 
47
49
  # @api private
48
50
 
@@ -54,10 +56,10 @@ module Selenium
54
56
  # Create a new Driver instance with the correct bridge for the given browser
55
57
  #
56
58
  # @overload for(browser)
57
- # @param [:ie, :internet_explorer, :edge, :remote, :chrome, :firefox, :ff, :phantomjs, :safari] browser The browser to
59
+ # @param [:ie, :internet_explorer, :edge, :remote, :chrome, :firefox, :ff, :safari] browser The browser to
58
60
  # create the driver for
59
61
  # @overload for(browser, opts)
60
- # @param [:ie, :internet_explorer, :edge, :remote, :chrome, :firefox, :ff, :phantomjs, :safari] browser The browser to
62
+ # @param [:ie, :internet_explorer, :edge, :remote, :chrome, :firefox, :ff, :safari] browser The browser to
61
63
  # create the driver for
62
64
  # @param [Hash] opts Options passed to Driver.new
63
65
  #
@@ -68,14 +70,13 @@ module Selenium
68
70
  # @see Selenium::WebDriver::IE::Driver
69
71
  # @see Selenium::WebDriver::Edge::Driver
70
72
  # @see Selenium::WebDriver::Chrome::Driver
71
- # @see Selenium::WebDriver::PhantomJS::Driver
72
73
  # @see Selenium::WebDriver::Safari::Driver
73
74
  #
74
75
  # @example
75
76
  #
76
77
  # WebDriver.for :firefox, profile: 'some-profile'
77
78
  # WebDriver.for :firefox, profile: Profile.new
78
- # WebDriver.for :remote, url: "http://localhost:4444/wd/hub", desired_capabilities: caps
79
+ # WebDriver.for :remote, url: "http://localhost:4444/wd/hub", capabilities: caps
79
80
  #
80
81
  # One special argument is not passed on to the bridges, :listener.
81
82
  # You can pass a listener for this option to get notified of WebDriver events.
@@ -11,37 +11,56 @@ Gem::Specification.new do |s|
11
11
  s.version = Selenium::WebDriver::VERSION
12
12
 
13
13
  s.authors = ['Alex Rodionov', 'Titus Fortner', 'Thomas Walpole']
14
- s.email = ['p0deje@gmail.com', 'titusfortner@gmail.com', 'twalpole@gmail.com']
14
+ s.email = %w[p0deje@gmail.com titusfortner@gmail.com twalpole@gmail.com]
15
15
 
16
- s.summary = 'The next generation developer focused tool for automated testing of webapps'
17
- s.description = 'WebDriver is a tool for writing automated tests of websites. ' \
18
- 'It aims to mimic the behaviour of a real user, ' \
19
- 'and as such interacts with the HTML of the application.'
16
+ s.summary = 'Selenium is a browser automation tool for automated testing of webapps and more'
17
+ s.description = <<-DESCRIPTION
18
+ Selenium implements the W3C WebDriver protocol to automate popular browsers.
19
+ It aims to mimic the behaviour of a real user as it interacts with the application's HTML.
20
+ It's primarily intended for web application testing, but any web-based task can automated.
21
+ DESCRIPTION
20
22
 
21
23
  s.license = 'Apache-2.0'
22
- s.homepage = 'https://github.com/SeleniumHQ/selenium'
24
+ s.homepage = 'https://selenium.dev'
23
25
  s.metadata = {
24
- 'changelog_uri' => 'https://github.com/SeleniumHQ/selenium/blob/master/rb/CHANGES',
25
- 'source_code_uri' => 'https://github.com/SeleniumHQ/selenium/tree/master/rb'
26
+ 'changelog_uri' => 'https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES',
27
+ 'source_code_uri' => 'https://github.com/SeleniumHQ/selenium/tree/trunk/rb',
28
+ 'rubygems_mfa_required' => 'true'
26
29
  }
27
30
 
28
31
  s.required_rubygems_version = Gem::Requirement.new('> 1.3.1') if s.respond_to? :required_rubygems_version=
29
- s.required_ruby_version = Gem::Requirement.new('>= 2.3')
32
+ s.required_ruby_version = Gem::Requirement.new('>= 2.7')
33
+
34
+ s.files = [
35
+ 'CHANGES',
36
+ 'LICENSE',
37
+ 'NOTICE',
38
+ 'Gemfile',
39
+ 'README.md',
40
+ 'selenium-webdriver.gemspec',
41
+ 'lib/selenium-webdriver.rb',
42
+ 'lib/selenium/server.rb',
43
+ 'lib/selenium/webdriver.rb'
44
+ ] + Dir['lib/selenium/webdriver/**/*']
30
45
 
31
- s.files = Dir[root + '/**/*'].reject { |e| e =~ /ruby\.iml|build\.desc/ }.map { |e| e.sub(root + '/', '') }
32
46
  s.require_paths = ['lib']
33
47
 
34
- s.add_runtime_dependency 'childprocess', ['>= 0.5', '< 4.0']
35
- s.add_runtime_dependency 'rubyzip', ['>= 1.2.2']
48
+ s.add_runtime_dependency 'childprocess', ['>= 0.5', '< 5.0']
49
+ s.add_runtime_dependency 'rexml', ['~> 3.2', '>= 3.2.5']
50
+ s.add_runtime_dependency 'rubyzip', ['>= 1.2.2', '< 3.0']
51
+ s.add_runtime_dependency 'websocket', ['~> 1.0']
36
52
 
37
53
  # childprocess requires ffi on windows but doesn't declare it in its dependencies
38
54
  s.add_development_dependency 'ffi'
55
+ s.add_development_dependency 'pry', ['~> 0.14']
39
56
  s.add_development_dependency 'rack', ['~> 2.0']
40
57
  s.add_development_dependency 'rake'
41
58
  s.add_development_dependency 'rspec', ['~> 3.0']
42
- s.add_development_dependency 'rubocop', ['~> 0.67.0']
59
+ s.add_development_dependency 'rubocop', ['~> 1.22']
43
60
  s.add_development_dependency 'rubocop-performance'
61
+ s.add_development_dependency 'rubocop-rake'
44
62
  s.add_development_dependency 'rubocop-rspec'
45
63
  s.add_development_dependency 'webmock', ['~> 3.5']
64
+ s.add_development_dependency 'webrick', ['~> 1.7']
46
65
  s.add_development_dependency 'yard', ['~> 0.9.11']
47
66
  end