selenium-webdriver 4.5.0 → 4.16.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +219 -1
  3. data/Gemfile +3 -0
  4. data/LICENSE +1 -1
  5. data/NOTICE +1 -1
  6. data/README.md +2 -2
  7. data/bin/linux/selenium-manager +0 -0
  8. data/bin/macos/selenium-manager +0 -0
  9. data/bin/windows/selenium-manager.exe +0 -0
  10. data/lib/selenium/server.rb +8 -22
  11. data/lib/selenium/webdriver/atoms/findElements.js +5 -5
  12. data/lib/selenium/webdriver/atoms/getAttribute.js +0 -0
  13. data/lib/selenium/webdriver/atoms/isDisplayed.js +2 -1
  14. data/lib/selenium/webdriver/atoms/mutationListener.js +0 -0
  15. data/lib/selenium/webdriver/atoms.rb +5 -3
  16. data/lib/selenium/webdriver/bidi/browsing_context.rb +88 -0
  17. data/lib/selenium/webdriver/bidi/browsing_context_info.rb +35 -0
  18. data/lib/selenium/webdriver/bidi/log/base_log_entry.rb +35 -0
  19. data/lib/selenium/webdriver/bidi/log/console_log_entry.rb +35 -0
  20. data/lib/selenium/webdriver/{common/driver_extensions/has_location.rb → bidi/log/filter_by.rb} +14 -11
  21. data/lib/selenium/webdriver/bidi/log/generic_log_entry.rb +33 -0
  22. data/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb +33 -0
  23. data/lib/selenium/webdriver/bidi/log_inspector.rb +143 -0
  24. data/lib/selenium/webdriver/bidi/navigate_result.rb +33 -0
  25. data/lib/selenium/webdriver/bidi/session.rb +13 -0
  26. data/lib/selenium/webdriver/bidi.rb +3 -2
  27. data/lib/selenium/webdriver/chrome/driver.rb +9 -30
  28. data/lib/selenium/webdriver/chrome/features.rb +8 -71
  29. data/lib/selenium/webdriver/chrome/options.rb +3 -237
  30. data/lib/selenium/webdriver/chrome/profile.rb +3 -83
  31. data/lib/selenium/webdriver/chrome/service.rb +4 -19
  32. data/lib/selenium/webdriver/chrome.rb +0 -2
  33. data/lib/selenium/webdriver/chromium/driver.rb +60 -0
  34. data/lib/selenium/webdriver/chromium/features.rb +99 -0
  35. data/lib/selenium/webdriver/chromium/options.rb +243 -0
  36. data/lib/selenium/webdriver/chromium/profile.rb +113 -0
  37. data/lib/selenium/webdriver/chromium.rb +29 -0
  38. data/lib/selenium/webdriver/common/action_builder.rb +11 -58
  39. data/lib/selenium/webdriver/common/child_process.rb +124 -0
  40. data/lib/selenium/webdriver/common/driver.rb +19 -36
  41. data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +0 -2
  42. data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +0 -1
  43. data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +0 -2
  44. data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +0 -2
  45. data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +0 -2
  46. data/lib/selenium/webdriver/common/driver_extensions/has_bidi.rb +0 -2
  47. data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +0 -1
  48. data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +0 -2
  49. data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +0 -2
  50. data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +0 -2
  51. data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +0 -2
  52. data/lib/selenium/webdriver/common/driver_extensions/has_file_downloads.rb +65 -0
  53. data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +0 -2
  54. data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +0 -1
  55. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +0 -2
  56. data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +0 -2
  57. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +0 -2
  58. data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +0 -2
  59. data/lib/selenium/webdriver/common/driver_finder.rb +45 -0
  60. data/lib/selenium/webdriver/common/element.rb +6 -6
  61. data/lib/selenium/webdriver/common/error.rb +27 -4
  62. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +2 -2
  63. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +3 -3
  64. data/lib/selenium/webdriver/common/interactions/pointer_move.rb +2 -2
  65. data/lib/selenium/webdriver/common/interactions/scroll.rb +7 -5
  66. data/lib/selenium/webdriver/common/local_driver.rb +46 -0
  67. data/lib/selenium/webdriver/common/logger.rb +91 -26
  68. data/lib/selenium/webdriver/common/options.rb +15 -8
  69. data/lib/selenium/webdriver/common/platform.rb +8 -49
  70. data/lib/selenium/webdriver/common/port_prober.rb +1 -1
  71. data/lib/selenium/webdriver/common/profile_helper.rb +1 -1
  72. data/lib/selenium/webdriver/common/proxy.rb +2 -2
  73. data/lib/selenium/webdriver/common/selenium_manager.rb +140 -0
  74. data/lib/selenium/webdriver/common/service.rb +21 -30
  75. data/lib/selenium/webdriver/common/service_manager.rb +6 -12
  76. data/lib/selenium/webdriver/common/shadow_root.rb +1 -2
  77. data/lib/selenium/webdriver/common/socket_lock.rb +3 -3
  78. data/lib/selenium/webdriver/common/socket_poller.rb +1 -1
  79. data/lib/selenium/webdriver/common/takes_screenshot.rb +2 -3
  80. data/lib/selenium/webdriver/common/target_locator.rb +2 -3
  81. data/lib/selenium/webdriver/common/timeouts.rb +2 -2
  82. data/lib/selenium/webdriver/common/virtual_authenticator/credential.rb +8 -6
  83. data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator.rb +0 -1
  84. data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator_options.rb +16 -16
  85. data/lib/selenium/webdriver/common/websocket_connection.rb +12 -4
  86. data/lib/selenium/webdriver/common.rb +5 -2
  87. data/lib/selenium/webdriver/devtools/console_event.rb +0 -2
  88. data/lib/selenium/webdriver/devtools/exception_event.rb +0 -2
  89. data/lib/selenium/webdriver/devtools/mutation_event.rb +0 -2
  90. data/lib/selenium/webdriver/devtools/network_interceptor.rb +4 -7
  91. data/lib/selenium/webdriver/devtools/pinned_script.rb +0 -2
  92. data/lib/selenium/webdriver/devtools/request.rb +0 -2
  93. data/lib/selenium/webdriver/devtools/response.rb +0 -2
  94. data/lib/selenium/webdriver/devtools.rb +11 -2
  95. data/lib/selenium/webdriver/edge/driver.rb +9 -3
  96. data/lib/selenium/webdriver/edge/features.rb +7 -4
  97. data/lib/selenium/webdriver/edge/options.rb +17 -5
  98. data/lib/selenium/webdriver/edge/profile.rb +2 -2
  99. data/lib/selenium/webdriver/edge/service.rb +8 -7
  100. data/lib/selenium/webdriver/edge.rb +0 -2
  101. data/lib/selenium/webdriver/firefox/driver.rb +8 -2
  102. data/lib/selenium/webdriver/firefox/features.rb +5 -2
  103. data/lib/selenium/webdriver/firefox/options.rb +2 -14
  104. data/lib/selenium/webdriver/firefox/profile.rb +10 -8
  105. data/lib/selenium/webdriver/firefox/service.rb +0 -18
  106. data/lib/selenium/webdriver/ie/driver.rb +7 -1
  107. data/lib/selenium/webdriver/{common/driver_extensions/has_network_connection.rb → ie/features.rb} +8 -11
  108. data/lib/selenium/webdriver/ie/options.rb +4 -3
  109. data/lib/selenium/webdriver/ie/service.rb +0 -22
  110. data/lib/selenium/webdriver/ie.rb +4 -3
  111. data/lib/selenium/webdriver/remote/{commands.rb → bridge/commands.rb} +0 -8
  112. data/lib/selenium/webdriver/remote/bridge.rb +13 -37
  113. data/lib/selenium/webdriver/remote/capabilities.rb +3 -53
  114. data/lib/selenium/webdriver/remote/driver.rb +35 -13
  115. data/lib/selenium/webdriver/remote/features.rb +75 -0
  116. data/lib/selenium/webdriver/remote/http/common.rb +3 -3
  117. data/lib/selenium/webdriver/remote/http/curb.rb +1 -3
  118. data/lib/selenium/webdriver/remote/http/default.rb +2 -2
  119. data/lib/selenium/webdriver/remote/response.rb +0 -1
  120. data/lib/selenium/webdriver/remote/server_error.rb +1 -1
  121. data/lib/selenium/webdriver/remote.rb +1 -1
  122. data/lib/selenium/webdriver/safari/driver.rb +7 -1
  123. data/lib/selenium/webdriver/safari/features.rb +5 -3
  124. data/lib/selenium/webdriver/safari/options.rb +5 -1
  125. data/lib/selenium/webdriver/safari/service.rb +10 -4
  126. data/lib/selenium/webdriver/safari.rb +1 -1
  127. data/lib/selenium/webdriver/support/color.rb +17 -17
  128. data/lib/selenium/webdriver/support/event_firing_bridge.rb +2 -2
  129. data/lib/selenium/webdriver/support/guards/guard.rb +6 -5
  130. data/lib/selenium/webdriver/support/guards/guard_condition.rb +0 -2
  131. data/lib/selenium/webdriver/support/guards.rb +1 -1
  132. data/lib/selenium/webdriver/support/relative_locator.rb +0 -1
  133. data/lib/selenium/webdriver/support/select.rb +2 -5
  134. data/lib/selenium/webdriver/version.rb +1 -1
  135. data/lib/selenium/webdriver.rb +5 -4
  136. data/selenium-webdriver.gemspec +10 -11
  137. metadata +43 -84
  138. data/lib/selenium/webdriver/support/cdp/domain.rb.erb +0 -63
  139. data/lib/selenium/webdriver/support/cdp_client_generator.rb +0 -108
@@ -0,0 +1,75 @@
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 Features
24
+ REMOTE_COMMANDS = {
25
+ upload_file: [:post, 'session/:session_id/se/file'],
26
+ get_downloadable_files: [:get, 'session/:session_id/se/files'],
27
+ download_file: [:post, 'session/:session_id/se/files'],
28
+ delete_downloadable_files: [:delete, 'session/:session_id/se/files']
29
+ }.freeze
30
+
31
+ def add_commands(commands)
32
+ @command_list = command_list.merge(commands)
33
+ end
34
+
35
+ def command_list
36
+ @command_list ||= REMOTE_COMMANDS
37
+ end
38
+
39
+ def commands(command)
40
+ command_list[command]
41
+ end
42
+
43
+ def upload(local_file)
44
+ unless File.file?(local_file)
45
+ WebDriver.logger.error("File detector only works with files. #{local_file.inspect} isn`t a file!",
46
+ id: :file_detector)
47
+ raise Error::WebDriverError, "You are trying to upload something that isn't a file."
48
+ end
49
+
50
+ execute :upload_file, {}, {file: Zipper.zip_file(local_file)}
51
+ end
52
+
53
+ def upload_if_necessary(keys)
54
+ local_files = keys.first&.split("\n")&.map { |key| @file_detector.call(Array(key)) }&.compact
55
+ return keys unless local_files&.any?
56
+
57
+ keys = local_files.map { |local_file| upload(local_file) }
58
+ Array(keys.join("\n"))
59
+ end
60
+
61
+ def downloadable_files
62
+ execute :get_downloadable_files
63
+ end
64
+
65
+ def download_file(name)
66
+ execute :download_file, {}, {name: name}
67
+ end
68
+
69
+ def delete_downloadable_files
70
+ execute :delete_downloadable_files
71
+ end
72
+ end
73
+ end # Remote
74
+ end # WebDriver
75
+ end # Selenium
@@ -49,8 +49,8 @@ module Selenium
49
49
  payload = JSON.generate(command_hash)
50
50
  headers['Content-Length'] = payload.bytesize.to_s if %i[post put].include?(verb)
51
51
 
52
- WebDriver.logger.info(" >>> #{url} | #{payload}")
53
- WebDriver.logger.debug(" > #{headers.inspect}")
52
+ WebDriver.logger.debug(" >>> #{url} | #{payload}", id: :command)
53
+ WebDriver.logger.debug(" > #{headers.inspect}", id: :header)
54
54
  elsif verb == :post
55
55
  payload = '{}'
56
56
  headers['Content-Length'] = '2'
@@ -75,7 +75,7 @@ module Selenium
75
75
  code = code.to_i
76
76
  body = body.to_s.strip
77
77
  content_type = content_type.to_s
78
- WebDriver.logger.info("<- #{body}")
78
+ WebDriver.logger.debug("<- #{body}", id: :command)
79
79
 
80
80
  if content_type.include? CONTENT_TYPE
81
81
  raise Error::WebDriverError, "empty body: #{content_type.inspect} (#{code})\n#{body}" if body.empty?
@@ -22,7 +22,6 @@ require 'curb'
22
22
  module Selenium
23
23
  module WebDriver
24
24
  module Remote
25
-
26
25
  module Http
27
26
  #
28
27
  # An alternative to the default Net::HTTP client.
@@ -38,7 +37,6 @@ module Selenium
38
37
  #
39
38
 
40
39
  class Curb < Common
41
-
42
40
  def quit_errors
43
41
  [Curl::Err::RecvError] + super
44
42
  end
@@ -85,7 +83,7 @@ module Selenium
85
83
  c.max_redirects = MAX_REDIRECTS
86
84
  c.follow_location = true
87
85
  c.timeout = @timeout if @timeout
88
- c.verbose = WebDriver.logger.info?
86
+ c.verbose = WebDriver.logger.debug?
89
87
 
90
88
  c
91
89
  end
@@ -16,8 +16,6 @@
16
16
  # KIND, either express or implied. See the License for the
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
-
20
- require 'net/https'
21
19
  require 'ipaddr'
22
20
 
23
21
  module Selenium
@@ -96,10 +94,12 @@ module Selenium
96
94
  end
97
95
 
98
96
  if response.is_a? Net::HTTPRedirection
97
+ WebDriver.logger.debug("Redirect to #{response['Location']}; times: #{redirects}")
99
98
  raise Error::WebDriverError, 'too many redirects' if redirects >= MAX_REDIRECTS
100
99
 
101
100
  request(:get, URI.parse(response['Location']), DEFAULT_HEADERS.dup, nil, redirects + 1)
102
101
  else
102
+ WebDriver.logger.debug(" <<< #{response.instance_variable_get(:@header).inspect}", id: :header)
103
103
  create_response response.code, response.body, response.content_type
104
104
  end
105
105
  end
@@ -20,7 +20,6 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Remote
23
-
24
23
  #
25
24
  # @api private
26
25
  #
@@ -25,7 +25,7 @@ module Selenium
25
25
  if response.is_a? String
26
26
  super(response)
27
27
  else
28
- super("status code #{response.code}")
28
+ super("status code #{response.code}; payload #{response.payload}")
29
29
  end
30
30
  end
31
31
  end # ServerError
@@ -23,11 +23,11 @@ require 'selenium/webdriver/remote/server_error'
23
23
  module Selenium
24
24
  module WebDriver
25
25
  module Remote
26
+ autoload :Features, 'selenium/webdriver/remote/features'
26
27
  autoload :Bridge, 'selenium/webdriver/remote/bridge'
27
28
  autoload :Driver, 'selenium/webdriver/remote/driver'
28
29
  autoload :Response, 'selenium/webdriver/remote/response'
29
30
  autoload :Capabilities, 'selenium/webdriver/remote/capabilities'
30
- autoload :COMMANDS, 'selenium/webdriver/remote/commands'
31
31
 
32
32
  module Http
33
33
  autoload :Common, 'selenium/webdriver/remote/http/common'
@@ -20,7 +20,6 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Safari
23
-
24
23
  #
25
24
  # Driver implementation for Safari.
26
25
  # @api private
@@ -31,6 +30,13 @@ module Selenium
31
30
  DriverExtensions::HasApplePermissions,
32
31
  DriverExtensions::HasWebStorage].freeze
33
32
 
33
+ include LocalDriver
34
+
35
+ def initialize(options: nil, service: nil, url: nil, **opts)
36
+ caps, url = initialize_local_driver(options, service, url)
37
+ super(caps: caps, url: url, **opts)
38
+ end
39
+
34
40
  def browser
35
41
  :safari
36
42
  end
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module Safari
23
23
  module Features
24
-
25
24
  # https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/WebDriverEndpointDoc/Commands/Commands.html
26
25
  SAFARI_COMMANDS = {
27
26
  get_permissions: [:get, 'session/:session_id/apple/permissions'],
@@ -29,8 +28,12 @@ module Selenium
29
28
  attach_debugger: [:post, 'session/:session_id/apple/attach_debugger']
30
29
  }.freeze
31
30
 
31
+ def command_list
32
+ SAFARI_COMMANDS.merge(self.class::COMMANDS)
33
+ end
34
+
32
35
  def commands(command)
33
- SAFARI_COMMANDS[command] || self.class::COMMANDS[command]
36
+ command_list[command]
34
37
  end
35
38
 
36
39
  def permissions
@@ -44,7 +47,6 @@ module Selenium
44
47
  def attach_debugger
45
48
  execute :attach_debugger, {}, {}
46
49
  end
47
-
48
50
  end # Bridge
49
51
  end # Safari
50
52
  end # WebDriver
@@ -26,7 +26,7 @@ module Selenium
26
26
  # @see https://developer.apple.com/documentation/webkit/about_webdriver_for_safari
27
27
  CAPABILITIES = {automatic_inspection: 'safari:automaticInspection',
28
28
  automatic_profiling: 'safari:automaticProfiling'}.freeze
29
- BROWSER = 'safari'
29
+ BROWSER = Selenium::WebDriver::Safari.technology_preview? ? 'Safari Technology Preview' : 'safari'
30
30
 
31
31
  def add_option(name, value = nil)
32
32
  key = name.is_a?(Hash) ? name.keys.first : name
@@ -35,6 +35,10 @@ module Selenium
35
35
  super
36
36
  end
37
37
 
38
+ def as_json(*)
39
+ @options[:browser_name] = Safari.technology_preview? ? 'Safari Technology Preview' : 'safari'
40
+ super
41
+ end
38
42
  end # Options
39
43
  end # Safari
40
44
  end # WebDriver
@@ -23,11 +23,17 @@ module Selenium
23
23
  class Service < WebDriver::Service
24
24
  DEFAULT_PORT = 7050
25
25
  EXECUTABLE = 'safaridriver'
26
- MISSING_TEXT = <<~ERROR
27
- Unable to find Apple's safaridriver which comes with Safari 10.
28
- More info at https://webkit.org/blog/6900/webdriver-support-in-safari-10/
29
- ERROR
30
26
  SHUTDOWN_SUPPORTED = false
27
+
28
+ def initialize(path: nil, port: nil, log: nil, args: nil)
29
+ raise Error::WebDriverError, 'Safari Service does not support setting log output' if log
30
+
31
+ super
32
+ end
33
+
34
+ def log=(*)
35
+ raise Error::WebDriverError, 'Safari Service does not support setting log output'
36
+ end
31
37
  end # Service
32
38
  end # Safari
33
39
  end # WebDriver
@@ -29,7 +29,7 @@ module Selenium
29
29
  attr_accessor :use_technology_preview
30
30
 
31
31
  def technology_preview
32
- "/Applications/Safari\ Technology\ Preview.app/Contents/MacOS/safaridriver"
32
+ '/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver'
33
33
  end
34
34
 
35
35
  def technology_preview!
@@ -21,29 +21,29 @@ module Selenium
21
21
  module WebDriver
22
22
  module Support
23
23
  class Color
24
- RGB_PATTERN = %r{^\s*rgb\(\s*(\d{1,3})\s*,
24
+ RGB_PATTERN = /^\s*rgb\(\s*(\d{1,3})\s*,
25
25
  \s*(\d{1,3})\s*,
26
- \s*(\d{1,3})\s*\)\s*$}x.freeze
27
- RGB_PCT_PATTERN = %r{^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,
26
+ \s*(\d{1,3})\s*\)\s*$/x
27
+ RGB_PCT_PATTERN = /^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,
28
28
  \s*(\d{1,3}|\d{1,2}\.\d+)%\s*,
29
- \s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$}x.freeze
30
- RGBA_PATTERN = %r{^\s*rgba\(\s*(\d{1,3})\s*,
29
+ \s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$/x
30
+ RGBA_PATTERN = /^\s*rgba\(\s*(\d{1,3})\s*,
31
31
  \s*(\d{1,3})\s*,
32
32
  \s*(\d{1,3})\s*,
33
- \s*(0|1|0\.\d+)\s*\)\s*$}x.freeze
34
- RGBA_PCT_PATTERN = %r{^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)
33
+ \s*(0|1|0\.\d+)\s*\)\s*$/x
34
+ RGBA_PCT_PATTERN = /^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)
35
35
  %\s*,\s*(\d{1,3}|\d{1,2}\.\d+)
36
36
  %\s*,\s*(\d{1,3}|\d{1,2}\.\d+)
37
- %\s*,\s*(0|1|0\.\d+)\s*\)\s*$}x.freeze
38
- HEX_PATTERN = /#(\h{2})(\h{2})(\h{2})/.freeze
39
- HEX3_PATTERN = /#(\h)(\h)(\h)/.freeze
40
- HSL_PATTERN = %r{^\s*hsl\(\s*(\d{1,3})\s*,
37
+ %\s*,\s*(0|1|0\.\d+)\s*\)\s*$/x
38
+ HEX_PATTERN = /#(\h{2})(\h{2})(\h{2})/
39
+ HEX3_PATTERN = /#(\h)(\h)(\h)/
40
+ HSL_PATTERN = /^\s*hsl\(\s*(\d{1,3})\s*,
41
41
  \s*(\d{1,3})%\s*,
42
- \s*(\d{1,3})%\s*\)\s*$}x.freeze
43
- HSLA_PATTERN = %r{^\s*hsla\(\s*(\d{1,3})\s*,
42
+ \s*(\d{1,3})%\s*\)\s*$/x
43
+ HSLA_PATTERN = /^\s*hsla\(\s*(\d{1,3})\s*,
44
44
  \s*(\d{1,3})%\s*,
45
45
  \s*(\d{1,3})%\s*,
46
- \s*(0|1|0\.\d+)\s*\)\s*$}x.freeze
46
+ \s*(0|1|0\.\d+)\s*\)\s*$/x
47
47
 
48
48
  attr_reader :red, :green, :blue, :alpha
49
49
 
@@ -83,8 +83,8 @@ 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 * (s + 1) : l + s - (l * s)
87
+ luminocity1 = (l * 2) - luminocity2
88
88
 
89
89
  r = hue_to_rgb(luminocity1, luminocity2, h + (1.0 / 3.0))
90
90
  g = hue_to_rgb(luminocity1, luminocity2, h)
@@ -122,7 +122,7 @@ module Selenium
122
122
 
123
123
  [red, green, blue, alpha] == [other.red, other.green, other.blue, other.alpha]
124
124
  end
125
- alias_method :eql?, :==
125
+ alias eql? ==
126
126
 
127
127
  def hash
128
128
  [red, green, blue, alpha, self.class].hash
@@ -120,8 +120,8 @@ module Selenium
120
120
  returned
121
121
  end
122
122
 
123
- def method_missing(meth, *args, &blk) # rubocop:disable Style/MissingRespondToMissing
124
- @delegate.__send__(meth, *args, &blk)
123
+ def method_missing(meth, ...) # rubocop:disable Style/MissingRespondToMissing
124
+ @delegate.__send__(meth, ...)
125
125
  end
126
126
  end # EventFiringBridge
127
127
  end # Support
@@ -21,14 +21,12 @@ module Selenium
21
21
  module WebDriver
22
22
  module Support
23
23
  class Guards
24
-
25
24
  #
26
25
  # Guard derived from RSpec example metadata.
27
26
  # @api private
28
27
  #
29
28
 
30
29
  class Guard
31
-
32
30
  attr_reader :guarded, :type, :messages, :reason
33
31
 
34
32
  def initialize(guarded, type, guards = nil)
@@ -55,7 +53,9 @@ module Selenium
55
53
 
56
54
  case @type
57
55
  when :exclude
58
- "Test not guarded because it breaks test run; #{details}"
56
+ "Test skipped because it breaks test run; #{details}"
57
+ when :flaky
58
+ "Test skipped because it is unreliable in this configuration; #{details}"
59
59
  when :exclusive
60
60
  "Test does not apply to this configuration; #{details}"
61
61
  else
@@ -73,9 +73,10 @@ module Selenium
73
73
  @type == :only
74
74
  end
75
75
 
76
- # Bug is present on all configurations specified, but test can not be run because it breaks other tests
76
+ # Bug is present on all configurations specified, but test can not be run because it breaks other tests,
77
+ # or it is flaky and unreliable
77
78
  def exclude?
78
- @type == :exclude
79
+ @type == :exclude || @type == :flaky
79
80
  end
80
81
 
81
82
  # Test only applies to configurations specified
@@ -21,7 +21,6 @@ module Selenium
21
21
  module WebDriver
22
22
  module Support
23
23
  class Guards
24
-
25
24
  #
26
25
  # Guard derived from RSpec example metadata.
27
26
  # @api private
@@ -44,7 +43,6 @@ module Selenium
44
43
 
45
44
  list.empty? || @execution.call(list)
46
45
  end
47
-
48
46
  end # GuardCondition
49
47
  end # Guards
50
48
  end # Support
@@ -24,7 +24,7 @@ module Selenium
24
24
  module WebDriver
25
25
  module Support
26
26
  class Guards
27
- GUARD_TYPES = %i[except only exclude exclusive].freeze
27
+ GUARD_TYPES = %i[except only exclude exclusive flaky].freeze
28
28
 
29
29
  attr_reader :messages
30
30
  attr_accessor :bug_tracker
@@ -20,7 +20,6 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Support
23
-
24
23
  #
25
24
  # @api private
26
25
  #
@@ -26,11 +26,8 @@ module Selenium
26
26
  #
27
27
 
28
28
  def initialize(element)
29
- unless element.enabled?
30
- raise Error::UnsupportedOperationError, 'Select element is disabled and may not be used.'
31
- end
32
-
33
29
  tag_name = element.tag_name
30
+
34
31
  raise ArgumentError, "unexpected tag name #{tag_name.inspect}" unless tag_name.casecmp('select').zero?
35
32
 
36
33
  @element = element
@@ -89,7 +86,7 @@ module Selenium
89
86
  #
90
87
  # <option value="foo">Bar</option>
91
88
  #
92
- # When slecting by :value, selects all options that have a value matching the argument. That is, when given "foo" this
89
+ # When selecting by :value, selects all options that have a value matching the argument. That is, when given "foo" this
93
90
  # would select an option like:
94
91
  #
95
92
  # <option value="foo">Bar</option>
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
- VERSION = '4.5.0'
22
+ VERSION = '4.16.0'
23
23
  end # WebDriver
24
24
  end # Selenium
@@ -17,13 +17,13 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- require 'childprocess'
21
20
  require 'tmpdir'
22
21
  require 'fileutils'
23
22
  require 'date'
24
23
  require 'json'
25
24
  require 'set'
26
25
  require 'uri'
26
+ require 'net/http'
27
27
 
28
28
  require 'selenium/webdriver/atoms'
29
29
  require 'selenium/webdriver/common'
@@ -34,9 +34,9 @@ module Selenium
34
34
  Point = Struct.new(:x, :y)
35
35
  Dimension = Struct.new(:width, :height)
36
36
  Rectangle = Struct.new(:x, :y, :width, :height)
37
- Location = Struct.new(:latitude, :longitude, :altitude)
38
37
 
39
38
  autoload :BiDi, 'selenium/webdriver/bidi'
39
+ autoload :Chromium, 'selenium/webdriver/chromium'
40
40
  autoload :Chrome, 'selenium/webdriver/chrome'
41
41
  autoload :DevTools, 'selenium/webdriver/devtools'
42
42
  autoload :Edge, 'selenium/webdriver/edge'
@@ -95,8 +95,9 @@ module Selenium
95
95
  # @return [Logger]
96
96
  #
97
97
 
98
- def self.logger
99
- @logger ||= WebDriver::Logger.new
98
+ def self.logger(**opts)
99
+ level = $DEBUG || ENV.key?('DEBUG') ? :debug : :info
100
+ @logger ||= WebDriver::Logger.new('Selenium', default_level: level, **opts)
100
101
  end
101
102
  end # WebDriver
102
103
  end # Selenium
@@ -24,12 +24,13 @@ Gem::Specification.new do |s|
24
24
  s.homepage = 'https://selenium.dev'
25
25
  s.metadata = {
26
26
  'changelog_uri' => 'https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES',
27
+ 'github_repo' => 'ssh://github.com/SeleniumHQ/selenium',
27
28
  'source_code_uri' => 'https://github.com/SeleniumHQ/selenium/tree/trunk/rb',
28
29
  'rubygems_mfa_required' => 'true'
29
30
  }
30
31
 
31
32
  s.required_rubygems_version = Gem::Requirement.new('> 1.3.1') if s.respond_to? :required_rubygems_version=
32
- s.required_ruby_version = Gem::Requirement.new('>= 2.7')
33
+ s.required_ruby_version = Gem::Requirement.new('>= 3.0')
33
34
 
34
35
  s.files = [
35
36
  'CHANGES',
@@ -41,25 +42,23 @@ Gem::Specification.new do |s|
41
42
  'lib/selenium-webdriver.rb',
42
43
  'lib/selenium/server.rb',
43
44
  'lib/selenium/webdriver.rb'
44
- ] + Dir['lib/selenium/webdriver/**/*']
45
+ ]
46
+ s.files += Dir['bin/**/*']
47
+ s.files += Dir['lib/selenium/webdriver/**/*']
45
48
 
49
+ s.bindir = 'bin'
46
50
  s.require_paths = ['lib']
47
51
 
48
- s.add_runtime_dependency 'childprocess', ['>= 0.5', '< 5.0']
49
52
  s.add_runtime_dependency 'rexml', ['~> 3.2', '>= 3.2.5']
50
53
  s.add_runtime_dependency 'rubyzip', ['>= 1.2.2', '< 3.0']
51
54
  s.add_runtime_dependency 'websocket', ['~> 1.0']
52
55
 
53
- # childprocess requires ffi on windows but doesn't declare it in its dependencies
54
- s.add_development_dependency 'ffi'
55
- s.add_development_dependency 'pry', ['~> 0.14']
56
56
  s.add_development_dependency 'rack', ['~> 2.0']
57
- s.add_development_dependency 'rake'
57
+ s.add_development_dependency 'rake', ['~> 13.0']
58
58
  s.add_development_dependency 'rspec', ['~> 3.0']
59
- s.add_development_dependency 'rubocop', ['~> 1.31']
60
- s.add_development_dependency 'rubocop-performance', ['~> 1.13']
61
- s.add_development_dependency 'rubocop-rake'
62
- s.add_development_dependency 'rubocop-rspec', ['~> 2.12']
59
+ s.add_development_dependency 'rubocop', ['~> 1.42']
60
+ s.add_development_dependency 'rubocop-performance', ['~> 1.15']
61
+ s.add_development_dependency 'rubocop-rspec', ['~> 2.16']
63
62
  s.add_development_dependency 'webmock', ['~> 3.5']
64
63
  s.add_development_dependency 'webrick', ['~> 1.7']
65
64
  s.add_development_dependency 'yard', ['~> 0.9.11']