selenium-webdriver 4.1.0 → 4.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +141 -1
  3. data/LICENSE +1 -1
  4. data/NOTICE +1 -1
  5. data/bin/linux/selenium-manager +0 -0
  6. data/bin/macos/selenium-manager +0 -0
  7. data/bin/windows/selenium-manager.exe +0 -0
  8. data/lib/selenium/server.rb +34 -26
  9. data/lib/selenium/webdriver/atoms/findElements.js +0 -0
  10. data/lib/selenium/webdriver/atoms/getAttribute.js +0 -0
  11. data/lib/selenium/webdriver/atoms/isDisplayed.js +0 -0
  12. data/lib/selenium/webdriver/atoms/mutationListener.js +0 -0
  13. data/lib/selenium/webdriver/bidi/session.rb +38 -0
  14. data/lib/selenium/webdriver/bidi.rb +55 -0
  15. data/lib/selenium/webdriver/chrome/driver.rb +1 -0
  16. data/lib/selenium/webdriver/chrome/features.rb +5 -0
  17. data/lib/selenium/webdriver/chrome/options.rb +33 -19
  18. data/lib/selenium/webdriver/chrome/service.rb +1 -1
  19. data/lib/selenium/webdriver/chrome.rb +0 -14
  20. data/lib/selenium/webdriver/common/action_builder.rb +108 -21
  21. data/lib/selenium/webdriver/common/child_process.rb +126 -0
  22. data/lib/selenium/webdriver/common/driver.rb +22 -55
  23. data/lib/selenium/webdriver/common/driver_extensions/{has_remote_status.rb → has_bidi.rb} +12 -5
  24. data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +10 -0
  25. data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +1 -2
  26. data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +1 -1
  27. data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +2 -67
  28. data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +1 -1
  29. data/lib/selenium/webdriver/common/element.rb +2 -2
  30. data/lib/selenium/webdriver/common/error.rb +1 -1
  31. data/lib/selenium/webdriver/common/interactions/input_device.rb +10 -4
  32. data/lib/selenium/webdriver/common/interactions/interaction.rb +12 -25
  33. data/lib/selenium/webdriver/common/interactions/interactions.rb +24 -4
  34. data/lib/selenium/webdriver/common/interactions/key_actions.rb +5 -1
  35. data/lib/selenium/webdriver/common/interactions/key_input.rb +11 -27
  36. data/lib/selenium/webdriver/common/interactions/none_input.rb +10 -8
  37. data/lib/selenium/webdriver/common/interactions/pause.rb +49 -0
  38. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +59 -70
  39. data/lib/selenium/webdriver/common/interactions/pointer_cancel.rb +45 -0
  40. data/lib/selenium/webdriver/common/interactions/pointer_event_properties.rb +63 -0
  41. data/lib/selenium/webdriver/common/interactions/pointer_input.rb +15 -84
  42. data/lib/selenium/webdriver/common/interactions/pointer_move.rb +60 -0
  43. data/lib/selenium/webdriver/common/interactions/pointer_press.rb +85 -0
  44. data/lib/selenium/webdriver/common/interactions/scroll.rb +57 -0
  45. data/lib/selenium/webdriver/common/interactions/scroll_origin.rb +48 -0
  46. data/lib/selenium/webdriver/common/interactions/typing_interaction.rb +54 -0
  47. data/lib/selenium/webdriver/common/interactions/wheel_actions.rb +113 -0
  48. data/lib/selenium/webdriver/common/interactions/wheel_input.rb +42 -0
  49. data/lib/selenium/webdriver/common/keys.rb +1 -0
  50. data/lib/selenium/webdriver/common/manager.rb +0 -27
  51. data/lib/selenium/webdriver/common/options.rb +2 -9
  52. data/lib/selenium/webdriver/common/platform.rb +8 -5
  53. data/lib/selenium/webdriver/common/search_context.rb +0 -6
  54. data/lib/selenium/webdriver/common/selenium_manager.rb +91 -0
  55. data/lib/selenium/webdriver/common/service.rb +7 -3
  56. data/lib/selenium/webdriver/common/service_manager.rb +3 -12
  57. data/lib/selenium/webdriver/common/shadow_root.rb +1 -1
  58. data/lib/selenium/webdriver/common/socket_lock.rb +1 -2
  59. data/lib/selenium/webdriver/common/socket_poller.rb +1 -1
  60. data/lib/selenium/webdriver/common/takes_screenshot.rb +1 -1
  61. data/lib/selenium/webdriver/common/virtual_authenticator/credential.rb +83 -0
  62. data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator.rb +73 -0
  63. data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator_options.rb +62 -0
  64. data/lib/selenium/webdriver/common/websocket_connection.rb +165 -0
  65. data/lib/selenium/webdriver/common/window.rb +6 -6
  66. data/lib/selenium/webdriver/common/zipper.rb +1 -1
  67. data/lib/selenium/webdriver/common.rb +19 -3
  68. data/lib/selenium/webdriver/devtools/network_interceptor.rb +176 -0
  69. data/lib/selenium/webdriver/devtools/request.rb +1 -1
  70. data/lib/selenium/webdriver/devtools/response.rb +1 -1
  71. data/lib/selenium/webdriver/devtools.rb +6 -112
  72. data/lib/selenium/webdriver/edge/features.rb +1 -0
  73. data/lib/selenium/webdriver/firefox/driver.rb +1 -0
  74. data/lib/selenium/webdriver/firefox/features.rb +6 -5
  75. data/lib/selenium/webdriver/firefox/options.rb +5 -2
  76. data/lib/selenium/webdriver/firefox/profile.rb +1 -5
  77. data/lib/selenium/webdriver/firefox/util.rb +46 -0
  78. data/lib/selenium/webdriver/firefox.rb +1 -14
  79. data/lib/selenium/webdriver/ie.rb +0 -14
  80. data/lib/selenium/webdriver/remote/bridge.rb +54 -19
  81. data/lib/selenium/webdriver/remote/commands.rb +15 -6
  82. data/lib/selenium/webdriver/remote/driver.rb +0 -1
  83. data/lib/selenium/webdriver/remote/http/default.rb +6 -12
  84. data/lib/selenium/webdriver/remote/response.rb +2 -2
  85. data/lib/selenium/webdriver/safari/options.rb +1 -1
  86. data/lib/selenium/webdriver/safari.rb +0 -14
  87. data/lib/selenium/webdriver/support/cdp_client_generator.rb +4 -4
  88. data/lib/selenium/webdriver/support/color.rb +7 -7
  89. data/lib/selenium/webdriver/support/guards/guard_condition.rb +1 -1
  90. data/lib/selenium/webdriver/support/guards.rb +1 -1
  91. data/lib/selenium/webdriver/support/nightly_version_generator.rb +60 -0
  92. data/lib/selenium/webdriver/support/select.rb +3 -1
  93. data/lib/selenium/webdriver/version.rb +1 -1
  94. data/lib/selenium/webdriver.rb +1 -1
  95. data/selenium-webdriver.gemspec +14 -10
  96. metadata +66 -42
  97. data/lib/selenium/webdriver/remote/http/persistent.rb +0 -65
  98. data/lib/selenium/webdriver/support/cdp/domain.rb.erb +0 -63
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 40e4bef1fdee7ae817c56466ec231be400d677d56a8c8f46b797c6b3eba28de9
4
- data.tar.gz: a9c1af31f12db6096f06c2a89e487e40ea2bb53b8f6e46e5f77a3046f149bb34
3
+ metadata.gz: 792a45b1e527ca7fadf294d16b603fd1b4b0e34106416e4f655edfeee3bbe579
4
+ data.tar.gz: e8eeec7a8d1f1f68c4b53fa6b05ae32b7ad7a6c9c27df2c589167a23d72a78ec
5
5
  SHA512:
6
- metadata.gz: b5325d0fe9f5fdb721ed4a6daa1384d7876dc7a072dd52f46c73d76b1614434c123fff2b4a9d7de01538968eddfbad57f2e1a87f4dce0e560a850dcf21988840
7
- data.tar.gz: 3b345ac66d051c32267d1c4ef9b2dd70aea36e2c4e5bb35ce30197d748effca8fed460824d1961ad5a39340358fc9be3f200708a38557e5e878b09be1b0d61c0
6
+ metadata.gz: 70c50740152826fb3d53ceef70b844b9a736051197256fdd0b35a403f6d836cb0cb06e03e0836fc570a55a03d14d01f8c547a2a221e812a0ea1a35ad7a3fff82
7
+ data.tar.gz: 7dbec088649c81cb491f707416eeb3280874a6a468305098f50978f2cec7d372aa9bcba8095d80b4971b700f38bb72d3e6ed4664359e28ee5286510b255d22dd
data/CHANGES CHANGED
@@ -1,4 +1,144 @@
1
- 4.1.0 (2021-11-18)
1
+ 4.7.1 (2022-12-02)
2
+ =========================
3
+ Ruby:
4
+ * Fix bug preventing selenium manager from using Internet Explorer
5
+
6
+ 4.7.0 (2022-12-01)
7
+ =========================
8
+ BiDi:
9
+ * Released selenium-devtools 0.108.0 (supports CDP v85, v106, v107, v108)
10
+ * Fix bug with socket stability
11
+
12
+ Ruby:
13
+ * Remove dependency on ChildProcess gem in favor of native Process.spawn (#11251)
14
+ * Add support for Selenium Manager to work with IE Driver
15
+ * Improve error handling for Selenium Manager
16
+
17
+ Safari:
18
+ * Fix bug preventing Safari Options from being used with Safari Technology Preview
19
+
20
+ 4.6.1 (2022-11-04)
21
+ =========================
22
+ Ruby:
23
+ * fix bug preventing selenium-manager from being executable by default
24
+
25
+ 4.6.0 (2022-11-04)
26
+ =========================
27
+ BiDi:
28
+ * Released selenium-devtools 0.107.0 (supports CDP v85, v105, v106, v107)
29
+
30
+ Ruby:
31
+ * firefox scroll by amount is only failing on mac
32
+ * add initial support for selenium manager
33
+ * Revert "[rb] do not allow Select class to work with disabled selects"
34
+ * Make sure selenium-manager is packed into gem
35
+ * Fix platform list in #scroll_by guard
36
+
37
+ 4.5.0 (2022-09-28)
38
+ =========================
39
+
40
+ BiDi:
41
+ * Released selenium-devtools 0.105.0 (supports CDP v85, v103, v104, v105)
42
+ * Released selenium-devtools 0.106.0 (supports CDP v85, v104, v105, v106)
43
+ * Add HasBiDi support to Chrome
44
+
45
+ Ruby:
46
+ * Fix bug in Platform code
47
+ * Update Select class to error when elements are disabled (#10812)
48
+
49
+ Firefox:
50
+ * Add support for installing unsigned add-ons (#10265, thanks TamsilAmani!)
51
+ * Change accept_insecure_certificates to true by default (to match other bindings)
52
+ * Set debugger_address option to true by default
53
+
54
+ Server:
55
+ * Add support for initializing server class with arguments and log level
56
+
57
+ 4.4.0 (2022-08-09)
58
+ =========================
59
+
60
+ BiDi:
61
+ * Released selenium-devtools 0.103.1 to fix websocket dependency requirement
62
+ * Released selenium-devtools 0.104.0 (supports CDP v85, v102, v103, v104)
63
+ * Have network interceptor ignore cancelled requests (#10856)
64
+ * Improve websocket message handling
65
+
66
+ Chromium:
67
+ * Prevent users from setting w3c: false and warn for true (thanks Tamsil Amani!)
68
+
69
+ Ruby:
70
+ * Implement Virtual Authenticator (#10903, #10541) (thanks Tamsil Amani!)
71
+
72
+ 4.3.0 (2022-06-23)
73
+ =========================
74
+
75
+ BiDi:
76
+ * Released selenium-devtools 0.103.0 (supports CDP v85, v101, v102, v103)
77
+
78
+ Ruby:
79
+ * Allow specifying which button is clicked in pointer action class methods
80
+ * Remove deprecated `Persistent` http class
81
+ * Remove deprecated HasRemoteStatus module
82
+ * Remove deprecated `Manager#new_window` and `Manager#logs`
83
+ * `ActionBuilder#move_to` no longer attempts to move to top left corner of element
84
+ * Remove deprecated support for sending Service parameters directly to Driver constructor
85
+ * Remove deprecated setters and getters for driver path on Browser modules
86
+ * Remove deprecated support for passing in options argument to Options class
87
+ * Allow `:options` parameter to take `Options` instance argument like other languages
88
+ * Remove deprecated support for `:desired_capabilities` & `:options` with `Hash` argument
89
+
90
+ 4.2.1 (2022-05-31)
91
+ =========================
92
+
93
+ Ruby
94
+ * Fix bug in setting default duration in Actions constructor
95
+
96
+ 4.2.0 (2022-05-27)
97
+ =========================
98
+
99
+ BiDi:
100
+ * Released selenium-devtools 0.97.0 (supports CDP v85, v95, v96, v97)
101
+ * Released selenium-devtools 0.98.0 (supports CDP v85, v96, v97, v98)
102
+ * Released selenium-devtools 0.99.0 (supports CDP v85, v97, v98, v99)
103
+ * Released selenium-devtools 0.100.0 (supports CDP v85, v98, v99, v100)
104
+ * Released selenium-devtools 0.101.0 (supports CDP v85, v99, v100, v101)
105
+ * Released selenium-devtools 0.102.0 (supports CDP v85, v100, v101, v102)
106
+ * Implement simple BiDi connection
107
+ * Fix bug in initial BiDi implementation (thanks Boris Petrov!)
108
+ * Fix bug with mutating headers in request interception (#10574)
109
+ * Fix bug with empty response headers (thanks Viren Negi!)
110
+
111
+ Firefox:
112
+ * Add support to Firefox Options for environment capability
113
+ * Use addon parameter instead of path parameter to avoid using file detector
114
+ * Restore #from_name method to Firefox profile (#10146)
115
+
116
+ Chromium:
117
+ * Add support for casting desktop
118
+
119
+ Ruby:
120
+ * Updated minimum required Ruby version to 2.7
121
+ * Fix bug by not attempting to stop service process when it's not started (#10015)
122
+ * Fix bug to not stop service process when it's not started (thanks Atsushi Tatsuma!)
123
+ * Use driver endpoint to get page source instead of JavaScript
124
+ * Add zenkaku_hankaku key support
125
+ * Fix download support of Selenium Server
126
+ * Do not convert Tag Name to CSS Selector
127
+
128
+ ActionBuilder:
129
+ * Raise error if input device not found
130
+ * Move `TypingInteraction` from `Interactions::KeyInput` to `Interactions` module
131
+ * Throw better errors for `PointerInput` methods
132
+ * Allow each action interaction class to validate its own source
133
+ * Set all Interactions classes to private
134
+ * Allow device names to use a default id if one is not specified
135
+ * Deprecate default mouse and keyboard values in constructor, favoring devices parameter
136
+ * Add support for pointer event properties
137
+ * Implement scroll wheel support
138
+ * Deprecate ordered pair parameters for pause method in favor of keywords
139
+ * Deprecate move to element with offset changing origin to top left of element
140
+
141
+ 4.1.0 (2021-11-22)
2
142
  =========================
3
143
 
4
144
  DevTools:
data/LICENSE CHANGED
@@ -187,7 +187,7 @@
187
187
  same "printed page" as the copyright notice for easier
188
188
  identification within third-party archives.
189
189
 
190
- Copyright 2021 Software Freedom Conservancy (SFC)
190
+ Copyright 2022 Software Freedom Conservancy (SFC)
191
191
 
192
192
  Licensed under the Apache License, Version 2.0 (the "License");
193
193
  you may not use this file except in compliance with the License.
data/NOTICE CHANGED
@@ -1,2 +1,2 @@
1
- Copyright 2011-2021 Software Freedom Conservancy
1
+ Copyright 2011-2022 Software Freedom Conservancy
2
2
  Copyright 2004-2011 Selenium committers
Binary file
Binary file
Binary file
@@ -17,7 +17,7 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- require 'childprocess'
20
+ require 'selenium/webdriver/common/child_process'
21
21
  require 'selenium/webdriver/common/socket_poller'
22
22
  require 'net/http'
23
23
 
@@ -84,15 +84,15 @@ module Selenium
84
84
  return download_file_name if File.exist? download_file_name
85
85
 
86
86
  begin
87
- server = 'https://github.com/seleniumhq/selenium/releases/download'
88
- released = Net::HTTP.get_response(URI.parse("#{server}/selenium-#{required_version}/#{download_file_name}"))
87
+ download_location = available_assets[download_file_name]['browser_download_url']
88
+ released = Net::HTTP.get_response(URI.parse(download_location))
89
89
  redirected = URI.parse released.header['location']
90
90
 
91
91
  File.open(download_file_name, 'wb') do |destination|
92
92
  download_server(redirected, destination)
93
93
  end
94
94
  rescue StandardError
95
- FileUtils.rm download_file_name if File.exist? download_file_name
95
+ FileUtils.rm_rf download_file_name
96
96
  raise
97
97
  end
98
98
 
@@ -105,19 +105,24 @@ module Selenium
105
105
 
106
106
  def latest
107
107
  @latest ||= begin
108
- net_http_start('api.github.com') do |http|
109
- json = http.get('/repos/seleniumhq/selenium/releases').body
110
- all_assets = JSON.parse(json).map { |release| release['assets'] }.flatten
111
- server_assets = all_assets.map { |asset| asset['name'][/selenium-server-(\d+\.\d+\.\d+)\.jar/, 1] }.compact
112
- server_assets.map { |version| Gem::Version.new(version) }.max.version
113
- end
108
+ available = available_assets.keys.map { |key| key[/selenium-server-(\d+\.\d+\.\d+)\.jar/, 1] }
109
+ available.map { |asset| Gem::Version.new(asset) }.max.to_s
114
110
  end
115
111
  end
116
112
 
117
113
  # @api private
118
114
 
115
+ def available_assets
116
+ @available_assets ||= net_http_start('api.github.com') do |http|
117
+ json = http.get('/repos/seleniumhq/selenium/releases').body
118
+ all_assets = JSON.parse(json).map { |release| release['assets'] }.flatten
119
+ server_assets = all_assets.select { |asset| asset['name'].match(/selenium-server-(\d+\.\d+\.\d+)\.jar/) }
120
+ server_assets.each_with_object({}) { |asset, hash| hash[asset.delete('name')] = asset }
121
+ end
122
+ end
123
+
119
124
  def net_http_start(address, &block)
120
- http_proxy = ENV['http_proxy'] || ENV['HTTP_PROXY']
125
+ http_proxy = ENV.fetch('http_proxy', nil) || ENV.fetch('HTTP_PROXY', nil)
121
126
  if http_proxy
122
127
  http_proxy = "http://#{http_proxy}" unless http_proxy.start_with?('http://')
123
128
  uri = URI.parse(http_proxy)
@@ -177,15 +182,21 @@ module Selenium
177
182
  def initialize(jar, opts = {})
178
183
  raise Errno::ENOENT, jar unless File.exist?(jar)
179
184
 
180
- @jar = jar
181
- @host = '127.0.0.1'
182
- @role = opts.fetch(:role, 'standalone')
183
- @port = opts.fetch(:port, 4444)
184
- @timeout = opts.fetch(:timeout, 30)
185
+ @jar = jar
186
+ @host = '127.0.0.1'
187
+ @role = opts.fetch(:role, 'standalone')
188
+ @port = opts.fetch(:port, 4444)
189
+ @timeout = opts.fetch(:timeout, 30)
185
190
  @background = opts.fetch(:background, false)
186
- @log = opts[:log]
187
- @log_file = nil
188
- @additional_args = []
191
+ @additional_args = opts.fetch(:args, [])
192
+ @log = opts[:log]
193
+ if opts[:log_level]
194
+ @log ||= true
195
+ @additional_args << '--log-level'
196
+ @additional_args << opts[:log_level].to_s
197
+ end
198
+
199
+ @log_file = nil
189
200
  end
190
201
 
191
202
  def start
@@ -226,7 +237,7 @@ module Selenium
226
237
 
227
238
  begin
228
239
  @process.poll_for_exit(5)
229
- rescue ChildProcess::TimeoutError
240
+ rescue WebDriver::ChildProcess::TimeoutError
230
241
  @process.stop
231
242
  end
232
243
  rescue Errno::ECHILD
@@ -241,16 +252,13 @@ module Selenium
241
252
  properties = @additional_args.dup - @additional_args.delete_if { |arg| arg[/^-D/] }
242
253
  args = ['-jar', @jar, @role, '--port', @port.to_s]
243
254
  server_command = ['java'] + properties + args + @additional_args
244
- cp = ChildProcess.build(*server_command)
255
+ cp = WebDriver::ChildProcess.build(*server_command)
245
256
  WebDriver.logger.debug("Executing Process #{server_command}")
246
257
 
247
- io = cp.io
248
-
249
258
  if @log.is_a?(String)
250
- @log_file = File.open(@log, 'w')
251
- io.stdout = io.stderr = @log_file
259
+ cp.io = @log
252
260
  elsif @log
253
- io.inherit!
261
+ cp.io = :out
254
262
  end
255
263
 
256
264
  cp.detach = @background
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,38 @@
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
+ class BiDi
23
+ class Session
24
+ Status = Struct.new(:ready, :message)
25
+
26
+ def initialize(bidi)
27
+ @bidi = bidi
28
+ end
29
+
30
+ def status
31
+ status = @bidi.send_cmd('session.status')
32
+ Status.new(status['ready'], status['message'])
33
+ end
34
+
35
+ end # Session
36
+ end # BiDi
37
+ end # WebDriver
38
+ end # Selenium
@@ -0,0 +1,55 @@
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
+ class BiDi
23
+ autoload :Session, 'selenium/webdriver/bidi/session'
24
+
25
+ def initialize(url:)
26
+ @ws = WebSocketConnection.new(url: url)
27
+ end
28
+
29
+ def close
30
+ @ws.close
31
+ end
32
+
33
+ def callbacks
34
+ @ws.callbacks
35
+ end
36
+
37
+ def session
38
+ Session.new(self)
39
+ end
40
+
41
+ def send_cmd(method, **params)
42
+ data = {method: method, params: params.compact}
43
+ message = @ws.send_cmd(**data)
44
+ raise Error::WebDriverError, error_message(message) if message['error']
45
+
46
+ message['result']
47
+ end
48
+
49
+ def error_message(message)
50
+ "#{message['error']}: #{message['message']}\n#{message['stacktrace']}"
51
+ end
52
+
53
+ end # BiDi
54
+ end # WebDriver
55
+ end # Selenium
@@ -28,6 +28,7 @@ module Selenium
28
28
 
29
29
  class Driver < WebDriver::Driver
30
30
  EXTENSIONS = [DriverExtensions::HasCDP,
31
+ DriverExtensions::HasBiDi,
31
32
  DriverExtensions::HasCasting,
32
33
  DriverExtensions::HasNetworkConditions,
33
34
  DriverExtensions::HasNetworkInterception,
@@ -27,6 +27,7 @@ module Selenium
27
27
  get_cast_sinks: [:get, 'session/:session_id/goog/cast/get_sinks'],
28
28
  set_cast_sink_to_use: [:post, 'session/:session_id/goog/cast/set_sink_to_use'],
29
29
  start_cast_tab_mirroring: [:post, 'session/:session_id/goog/cast/start_tab_mirroring'],
30
+ start_cast_desktop_mirroring: [:post, 'session/:session_id/goog/cast/start_desktop_mirroring'],
30
31
  get_cast_issue_message: [:get, 'session/:session_id/goog/cast/get_issue_message'],
31
32
  stop_casting: [:post, 'session/:session_id/goog/cast/stop_casting'],
32
33
  get_network_conditions: [:get, 'session/:session_id/chromium/network_conditions'],
@@ -62,6 +63,10 @@ module Selenium
62
63
  execute :start_cast_tab_mirroring, {}, {sinkName: name}
63
64
  end
64
65
 
66
+ def start_cast_desktop_mirroring(name)
67
+ execute :start_cast_desktop_mirroring, {}, {sinkName: name}
68
+ end
69
+
65
70
  def stop_casting(name)
66
71
  execute :stop_casting, {}, {sinkName: name}
67
72
  end
@@ -52,22 +52,22 @@ module Selenium
52
52
  # options = Selenium::WebDriver::Chrome::Options.new(args: ['start-maximized', 'user-data-dir=/tmp/temp_profile'])
53
53
  # driver = Selenium::WebDriver.for(:chrome, capabilities: options)
54
54
  #
55
- # @param [Profile] :profile An instance of a Chrome::Profile Class
56
- # @param [Array] :encoded_extensions List of extensions that do not need to be Base64 encoded
55
+ # @param [Profile] profile An instance of a Chrome::Profile Class
57
56
  # @param [Hash] opts the pre-defined options to create the Chrome::Options with
58
- # @option opts [Array<String>] :args List of command-line arguments to use when starting Chrome
59
- # @option opts [String] :binary Path to the Chrome executable to use
60
- # @option opts [Hash] :prefs A hash with each entry consisting of the name of the preference and its value
61
- # @option opts [Array<String>] :extensions A list of paths to (.crx) Chrome extensions to install on startup
62
- # @option opts [Hash] :options A hash for raw options
63
- # @option opts [Hash] :emulation A hash for raw emulation options
64
- # @option opts [Hash] :local_state A hash for the Local State file in the user data folder
65
- # @option opts [Boolean] :detach whether browser is closed when the driver is sent the quit command
66
- # @option opts [String] :debugger_address address of a Chrome debugger server to connect to
67
- # @option opts [Array<String>] :exclude_switches command line switches to exclude
68
- # @option opts [String] :minidump_path Directory to store Chrome minidumps (linux only)
69
- # @option opts [Hash] :perf_logging_prefs A hash for performance logging preferences
70
- # @option opts [Array<String>] :window_types A list of window types to appear in the list of window handles
57
+ # @option opts [Array] encoded_extensions List of extensions that do not need to be Base64 encoded
58
+ # @option opts [Array<String>] args List of command-line arguments to use when starting Chrome
59
+ # @option opts [String] binary Path to the Chrome executable to use
60
+ # @option opts [Hash] prefs A hash with each entry consisting of the name of the preference and its value
61
+ # @option opts [Array<String>] extensions A list of paths to (.crx) Chrome extensions to install on startup
62
+ # @option opts [Hash] options A hash for raw options
63
+ # @option opts [Hash] emulation A hash for raw emulation options
64
+ # @option opts [Hash] local_state A hash for the Local State file in the user data folder
65
+ # @option opts [Boolean] detach whether browser is closed when the driver is sent the quit command
66
+ # @option opts [String] debugger_address address of a Chrome debugger server to connect to
67
+ # @option opts [Array<String>] exclude_switches command line switches to exclude
68
+ # @option opts [String] minidump_path Directory to store Chrome minidumps (linux only)
69
+ # @option opts [Hash] perf_logging_prefs A hash for performance logging preferences
70
+ # @option opts [Array<String>] window_types A list of window types to appear in the list of window handles
71
71
  #
72
72
 
73
73
  def initialize(profile: nil, **opts)
@@ -87,7 +87,7 @@ module Selenium
87
87
  @logging_prefs = options.delete(:logging_prefs) || {}
88
88
  @encoded_extensions = @options.delete(:encoded_extensions) || []
89
89
  @extensions = []
90
- (@options.delete(:extensions)).each(&method(:validate_extension))
90
+ @options.delete(:extensions).each { |ext| validate_extension(ext) }
91
91
  end
92
92
 
93
93
  #
@@ -112,11 +112,11 @@ module Selenium
112
112
  # options = Selenium::WebDriver::Chrome::Options.new
113
113
  # options.extensions = extensions
114
114
  #
115
- # @param [Array<String>] :extensions A list of paths to (.crx) Chrome extensions to install on startup
115
+ # @param [Array<String>] extensions A list of paths to (.crx) Chrome extensions to install on startup
116
116
  #
117
117
 
118
118
  def extensions=(extensions)
119
- extensions.each(&method(:validate_extension))
119
+ extensions.each { |ext| validate_extension(ext) }
120
120
  end
121
121
 
122
122
  #
@@ -227,6 +227,9 @@ module Selenium
227
227
 
228
228
  options = browser_options[self.class::KEY]
229
229
  options['binary'] ||= binary_path if binary_path
230
+
231
+ check_w3c(options[:w3c]) if options.key?(:w3c)
232
+
230
233
  if @profile
231
234
  options['args'] ||= []
232
235
  options['args'] << "--user-data-dir=#{@profile.directory}"
@@ -234,7 +237,18 @@ module Selenium
234
237
 
235
238
  return if (@encoded_extensions + @extensions).empty?
236
239
 
237
- options['extensions'] = @encoded_extensions + @extensions.map(&method(:encode_extension))
240
+ options['extensions'] = @encoded_extensions + @extensions.map { |ext| encode_extension(ext) }
241
+ end
242
+
243
+ def check_w3c(w3c)
244
+ if w3c
245
+ WebDriver.logger.warn("Setting 'w3c: true' is redundant and will no longer be allowed", id: :w3c)
246
+ return
247
+ end
248
+
249
+ raise Error::InvalidArgumentError,
250
+ "Setting 'w3c: false' is not allowed.\n" \
251
+ "Please update to W3C Syntax: https://www.selenium.dev/blog/2022/legacy-protocol-support/"
238
252
  end
239
253
 
240
254
  def binary_path
@@ -26,7 +26,7 @@ module Selenium
26
26
  MISSING_TEXT = <<~ERROR
27
27
  Unable to find chromedriver. Please download the server from
28
28
  https://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH.
29
- More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver.
29
+ More info at https://www.selenium.dev/documentation/webdriver/getting_started/install_drivers/?language=ruby.
30
30
  ERROR
31
31
  SHUTDOWN_SUPPORTED = true
32
32
 
@@ -28,20 +28,6 @@ module Selenium
28
28
  autoload :Options, 'selenium/webdriver/chrome/options'
29
29
  autoload :Service, 'selenium/webdriver/chrome/service'
30
30
 
31
- def self.driver_path=(path)
32
- WebDriver.logger.deprecate 'Selenium::WebDriver::Chrome#driver_path=',
33
- 'Selenium::WebDriver::Chrome::Service#driver_path=',
34
- id: :driver_path
35
- Selenium::WebDriver::Chrome::Service.driver_path = path
36
- end
37
-
38
- def self.driver_path
39
- WebDriver.logger.deprecate 'Selenium::WebDriver::Chrome#driver_path',
40
- 'Selenium::WebDriver::Chrome::Service#driver_path',
41
- id: :driver_path
42
- Selenium::WebDriver::Chrome::Service.driver_path
43
- end
44
-
45
31
  def self.path=(path)
46
32
  Platform.assert_executable path
47
33
  @path = path