selenium-webdriver 4.0.0.beta1 → 4.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES +89 -0
  3. data/Gemfile +3 -1
  4. data/NOTICE +2 -0
  5. data/lib/selenium/webdriver/atoms/findElements.js +77 -78
  6. data/lib/selenium/webdriver/atoms/getAttribute.js +64 -68
  7. data/lib/selenium/webdriver/atoms/isDisplayed.js +27 -27
  8. data/lib/selenium/webdriver/atoms/mutationListener.js +17 -0
  9. data/lib/selenium/webdriver/chrome/driver.rb +21 -18
  10. data/lib/selenium/webdriver/chrome/options.rb +1 -1
  11. data/lib/selenium/webdriver/chrome/profile.rb +5 -2
  12. data/lib/selenium/webdriver/chrome/service.rb +3 -1
  13. data/lib/selenium/webdriver/chrome.rb +1 -1
  14. data/lib/selenium/webdriver/common/driver.rb +23 -4
  15. data/lib/selenium/webdriver/{devtools/v87/schema.rb → common/driver_extensions/full_page_screenshot.rb} +16 -21
  16. data/lib/selenium/webdriver/{edge/bridge.rb → common/driver_extensions/has_cdp.rb} +12 -11
  17. data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +6 -1
  18. data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +1 -6
  19. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +4 -2
  20. data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +67 -0
  21. data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +77 -0
  22. data/lib/selenium/webdriver/common/driver_extensions/prints_page.rb +28 -1
  23. data/lib/selenium/webdriver/common/element.rb +75 -17
  24. data/lib/selenium/webdriver/common/error.rb +12 -0
  25. data/lib/selenium/webdriver/common/interactions/interaction.rb +4 -1
  26. data/lib/selenium/webdriver/common/logger.rb +5 -2
  27. data/lib/selenium/webdriver/common/options.rb +62 -17
  28. data/lib/selenium/webdriver/common/proxy.rb +6 -3
  29. data/lib/selenium/webdriver/common/search_context.rb +4 -1
  30. data/lib/selenium/webdriver/common/service.rb +1 -0
  31. data/lib/selenium/webdriver/common/shadow_root.rb +87 -0
  32. data/lib/selenium/webdriver/common/socket_poller.rb +19 -30
  33. data/lib/selenium/webdriver/common/takes_screenshot.rb +9 -6
  34. data/lib/selenium/webdriver/common.rb +5 -0
  35. data/lib/selenium/webdriver/{firefox/bridge.rb → devtools/pinned_script.rb} +28 -16
  36. data/lib/selenium/webdriver/devtools/{v87/console.rb → request.rb} +32 -34
  37. data/lib/selenium/webdriver/devtools.rb +35 -25
  38. data/lib/selenium/webdriver/edge/driver.rb +2 -6
  39. data/lib/selenium/webdriver/edge/options.rb +0 -0
  40. data/lib/selenium/webdriver/edge/profile.rb +0 -0
  41. data/lib/selenium/webdriver/edge.rb +1 -1
  42. data/lib/selenium/webdriver/firefox/driver.rb +14 -13
  43. data/lib/selenium/webdriver/firefox/features.rb +6 -1
  44. data/lib/selenium/webdriver/firefox.rb +5 -1
  45. data/lib/selenium/webdriver/ie/driver.rb +1 -1
  46. data/lib/selenium/webdriver/ie/options.rb +3 -1
  47. data/lib/selenium/webdriver/ie/service.rb +4 -2
  48. data/lib/selenium/webdriver/remote/bridge.rb +65 -14
  49. data/lib/selenium/webdriver/remote/capabilities.rb +105 -52
  50. data/lib/selenium/webdriver/remote/commands.rb +5 -0
  51. data/lib/selenium/webdriver/remote/driver.rb +8 -4
  52. data/lib/selenium/webdriver/remote/http/common.rb +0 -5
  53. data/lib/selenium/webdriver/remote/http/default.rb +5 -3
  54. data/lib/selenium/webdriver/remote.rb +1 -1
  55. data/lib/selenium/webdriver/safari/driver.rb +3 -7
  56. data/lib/selenium/webdriver/safari.rb +1 -1
  57. data/lib/selenium/webdriver/support/cdp/domain.rb.erb +63 -0
  58. data/lib/selenium/webdriver/support/cdp_client_generator.rb +108 -0
  59. data/lib/selenium/webdriver/support/event_firing_bridge.rb +2 -2
  60. data/lib/selenium/webdriver/support/guards/guard.rb +89 -0
  61. data/lib/selenium/webdriver/{devtools/v87/system_info.rb → support/guards/guard_condition.rb} +24 -24
  62. data/lib/selenium/webdriver/support/guards.rb +95 -0
  63. data/lib/selenium/webdriver/support/select.rb +2 -2
  64. data/lib/selenium/webdriver/version.rb +1 -1
  65. data/lib/selenium/webdriver.rb +0 -1
  66. data/selenium-webdriver.gemspec +21 -8
  67. metadata +62 -233
  68. data/lib/selenium/webdriver/chrome/bridge.rb +0 -66
  69. data/lib/selenium/webdriver/devtools/v85/accessibility.rb +0 -64
  70. data/lib/selenium/webdriver/devtools/v85/animation.rb +0 -100
  71. data/lib/selenium/webdriver/devtools/v85/application_cache.rb +0 -66
  72. data/lib/selenium/webdriver/devtools/v85/audits.rb +0 -63
  73. data/lib/selenium/webdriver/devtools/v85/background_service.rb +0 -69
  74. data/lib/selenium/webdriver/devtools/v85/browser.rb +0 -125
  75. data/lib/selenium/webdriver/devtools/v85/cache_storage.rb +0 -75
  76. data/lib/selenium/webdriver/devtools/v85/cast.rb +0 -72
  77. data/lib/selenium/webdriver/devtools/v85/console.rb +0 -59
  78. data/lib/selenium/webdriver/devtools/v85/css.rb +0 -167
  79. data/lib/selenium/webdriver/devtools/v85/database.rb +0 -66
  80. data/lib/selenium/webdriver/devtools/v85/debugger.rb +0 -231
  81. data/lib/selenium/webdriver/devtools/v85/device_orientation.rb +0 -55
  82. data/lib/selenium/webdriver/devtools/v85/dom.rb +0 -322
  83. data/lib/selenium/webdriver/devtools/v85/dom_debugger.rb +0 -95
  84. data/lib/selenium/webdriver/devtools/v85/dom_snapshot.rb +0 -67
  85. data/lib/selenium/webdriver/devtools/v85/dom_storage.rb +0 -81
  86. data/lib/selenium/webdriver/devtools/v85/emulation.rb +0 -182
  87. data/lib/selenium/webdriver/devtools/v85/fetch.rb +0 -99
  88. data/lib/selenium/webdriver/devtools/v85/headless_experimental.rb +0 -63
  89. data/lib/selenium/webdriver/devtools/v85/heap_profiler.rb +0 -109
  90. data/lib/selenium/webdriver/devtools/v85/indexed_db.rb +0 -102
  91. data/lib/selenium/webdriver/devtools/v85/input.rb +0 -143
  92. data/lib/selenium/webdriver/devtools/v85/inspector.rb +0 -57
  93. data/lib/selenium/webdriver/devtools/v85/io.rb +0 -61
  94. data/lib/selenium/webdriver/devtools/v85/layer_tree.rb +0 -97
  95. data/lib/selenium/webdriver/devtools/v85/log.rb +0 -68
  96. data/lib/selenium/webdriver/devtools/v85/media.rb +0 -59
  97. data/lib/selenium/webdriver/devtools/v85/memory.rb +0 -88
  98. data/lib/selenium/webdriver/devtools/v85/network.rb +0 -230
  99. data/lib/selenium/webdriver/devtools/v85/overlay.rb +0 -160
  100. data/lib/selenium/webdriver/devtools/v85/page.rb +0 -376
  101. data/lib/selenium/webdriver/devtools/v85/performance.rb +0 -65
  102. data/lib/selenium/webdriver/devtools/v85/profiler.rb +0 -113
  103. data/lib/selenium/webdriver/devtools/v85/runtime.rb +0 -196
  104. data/lib/selenium/webdriver/devtools/v85/schema.rb +0 -48
  105. data/lib/selenium/webdriver/devtools/v85/security.rb +0 -73
  106. data/lib/selenium/webdriver/devtools/v85/service_worker.rb +0 -118
  107. data/lib/selenium/webdriver/devtools/v85/storage.rb +0 -97
  108. data/lib/selenium/webdriver/devtools/v85/system_info.rb +0 -52
  109. data/lib/selenium/webdriver/devtools/v85/target.rb +0 -145
  110. data/lib/selenium/webdriver/devtools/v85/tethering.rb +0 -57
  111. data/lib/selenium/webdriver/devtools/v85/tracing.rb +0 -78
  112. data/lib/selenium/webdriver/devtools/v85/web_audio.rb +0 -72
  113. data/lib/selenium/webdriver/devtools/v85/web_authn.rb +0 -96
  114. data/lib/selenium/webdriver/devtools/v86/accessibility.rb +0 -64
  115. data/lib/selenium/webdriver/devtools/v86/animation.rb +0 -100
  116. data/lib/selenium/webdriver/devtools/v86/application_cache.rb +0 -66
  117. data/lib/selenium/webdriver/devtools/v86/audits.rb +0 -63
  118. data/lib/selenium/webdriver/devtools/v86/background_service.rb +0 -69
  119. data/lib/selenium/webdriver/devtools/v86/browser.rb +0 -125
  120. data/lib/selenium/webdriver/devtools/v86/cache_storage.rb +0 -75
  121. data/lib/selenium/webdriver/devtools/v86/cast.rb +0 -72
  122. data/lib/selenium/webdriver/devtools/v86/console.rb +0 -59
  123. data/lib/selenium/webdriver/devtools/v86/css.rb +0 -181
  124. data/lib/selenium/webdriver/devtools/v86/database.rb +0 -66
  125. data/lib/selenium/webdriver/devtools/v86/debugger.rb +0 -233
  126. data/lib/selenium/webdriver/devtools/v86/device_orientation.rb +0 -55
  127. data/lib/selenium/webdriver/devtools/v86/dom.rb +0 -329
  128. data/lib/selenium/webdriver/devtools/v86/dom_debugger.rb +0 -95
  129. data/lib/selenium/webdriver/devtools/v86/dom_snapshot.rb +0 -67
  130. data/lib/selenium/webdriver/devtools/v86/dom_storage.rb +0 -81
  131. data/lib/selenium/webdriver/devtools/v86/emulation.rb +0 -193
  132. data/lib/selenium/webdriver/devtools/v86/fetch.rb +0 -99
  133. data/lib/selenium/webdriver/devtools/v86/headless_experimental.rb +0 -63
  134. data/lib/selenium/webdriver/devtools/v86/heap_profiler.rb +0 -109
  135. data/lib/selenium/webdriver/devtools/v86/indexed_db.rb +0 -102
  136. data/lib/selenium/webdriver/devtools/v86/input.rb +0 -143
  137. data/lib/selenium/webdriver/devtools/v86/inspector.rb +0 -57
  138. data/lib/selenium/webdriver/devtools/v86/io.rb +0 -61
  139. data/lib/selenium/webdriver/devtools/v86/layer_tree.rb +0 -97
  140. data/lib/selenium/webdriver/devtools/v86/log.rb +0 -68
  141. data/lib/selenium/webdriver/devtools/v86/media.rb +0 -59
  142. data/lib/selenium/webdriver/devtools/v86/memory.rb +0 -88
  143. data/lib/selenium/webdriver/devtools/v86/network.rb +0 -235
  144. data/lib/selenium/webdriver/devtools/v86/overlay.rb +0 -183
  145. data/lib/selenium/webdriver/devtools/v86/page.rb +0 -376
  146. data/lib/selenium/webdriver/devtools/v86/performance.rb +0 -65
  147. data/lib/selenium/webdriver/devtools/v86/profiler.rb +0 -113
  148. data/lib/selenium/webdriver/devtools/v86/runtime.rb +0 -196
  149. data/lib/selenium/webdriver/devtools/v86/schema.rb +0 -48
  150. data/lib/selenium/webdriver/devtools/v86/security.rb +0 -73
  151. data/lib/selenium/webdriver/devtools/v86/service_worker.rb +0 -118
  152. data/lib/selenium/webdriver/devtools/v86/storage.rb +0 -97
  153. data/lib/selenium/webdriver/devtools/v86/system_info.rb +0 -52
  154. data/lib/selenium/webdriver/devtools/v86/target.rb +0 -145
  155. data/lib/selenium/webdriver/devtools/v86/tethering.rb +0 -57
  156. data/lib/selenium/webdriver/devtools/v86/tracing.rb +0 -78
  157. data/lib/selenium/webdriver/devtools/v86/web_audio.rb +0 -72
  158. data/lib/selenium/webdriver/devtools/v86/web_authn.rb +0 -102
  159. data/lib/selenium/webdriver/devtools/v87/accessibility.rb +0 -73
  160. data/lib/selenium/webdriver/devtools/v87/animation.rb +0 -100
  161. data/lib/selenium/webdriver/devtools/v87/application_cache.rb +0 -66
  162. data/lib/selenium/webdriver/devtools/v87/audits.rb +0 -63
  163. data/lib/selenium/webdriver/devtools/v87/background_service.rb +0 -69
  164. data/lib/selenium/webdriver/devtools/v87/browser.rb +0 -125
  165. data/lib/selenium/webdriver/devtools/v87/cache_storage.rb +0 -75
  166. data/lib/selenium/webdriver/devtools/v87/cast.rb +0 -72
  167. data/lib/selenium/webdriver/devtools/v87/css.rb +0 -181
  168. data/lib/selenium/webdriver/devtools/v87/database.rb +0 -66
  169. data/lib/selenium/webdriver/devtools/v87/debugger.rb +0 -233
  170. data/lib/selenium/webdriver/devtools/v87/device_orientation.rb +0 -55
  171. data/lib/selenium/webdriver/devtools/v87/dom.rb +0 -329
  172. data/lib/selenium/webdriver/devtools/v87/dom_debugger.rb +0 -95
  173. data/lib/selenium/webdriver/devtools/v87/dom_snapshot.rb +0 -67
  174. data/lib/selenium/webdriver/devtools/v87/dom_storage.rb +0 -81
  175. data/lib/selenium/webdriver/devtools/v87/emulation.rb +0 -193
  176. data/lib/selenium/webdriver/devtools/v87/fetch.rb +0 -99
  177. data/lib/selenium/webdriver/devtools/v87/headless_experimental.rb +0 -63
  178. data/lib/selenium/webdriver/devtools/v87/heap_profiler.rb +0 -109
  179. data/lib/selenium/webdriver/devtools/v87/indexed_db.rb +0 -102
  180. data/lib/selenium/webdriver/devtools/v87/input.rb +0 -143
  181. data/lib/selenium/webdriver/devtools/v87/inspector.rb +0 -57
  182. data/lib/selenium/webdriver/devtools/v87/io.rb +0 -61
  183. data/lib/selenium/webdriver/devtools/v87/layer_tree.rb +0 -97
  184. data/lib/selenium/webdriver/devtools/v87/log.rb +0 -68
  185. data/lib/selenium/webdriver/devtools/v87/media.rb +0 -59
  186. data/lib/selenium/webdriver/devtools/v87/memory.rb +0 -88
  187. data/lib/selenium/webdriver/devtools/v87/network.rb +0 -247
  188. data/lib/selenium/webdriver/devtools/v87/overlay.rb +0 -183
  189. data/lib/selenium/webdriver/devtools/v87/page.rb +0 -376
  190. data/lib/selenium/webdriver/devtools/v87/performance.rb +0 -65
  191. data/lib/selenium/webdriver/devtools/v87/profiler.rb +0 -125
  192. data/lib/selenium/webdriver/devtools/v87/runtime.rb +0 -196
  193. data/lib/selenium/webdriver/devtools/v87/security.rb +0 -73
  194. data/lib/selenium/webdriver/devtools/v87/service_worker.rb +0 -118
  195. data/lib/selenium/webdriver/devtools/v87/storage.rb +0 -97
  196. data/lib/selenium/webdriver/devtools/v87/target.rb +0 -145
  197. data/lib/selenium/webdriver/devtools/v87/tethering.rb +0 -57
  198. data/lib/selenium/webdriver/devtools/v87/tracing.rb +0 -78
  199. data/lib/selenium/webdriver/devtools/v87/web_audio.rb +0 -72
  200. data/lib/selenium/webdriver/devtools/v87/web_authn.rb +0 -102
  201. data/lib/selenium/webdriver/devtools/v88/accessibility.rb +0 -73
  202. data/lib/selenium/webdriver/devtools/v88/animation.rb +0 -100
  203. data/lib/selenium/webdriver/devtools/v88/application_cache.rb +0 -66
  204. data/lib/selenium/webdriver/devtools/v88/audits.rb +0 -63
  205. data/lib/selenium/webdriver/devtools/v88/background_service.rb +0 -69
  206. data/lib/selenium/webdriver/devtools/v88/browser.rb +0 -130
  207. data/lib/selenium/webdriver/devtools/v88/cache_storage.rb +0 -75
  208. data/lib/selenium/webdriver/devtools/v88/cast.rb +0 -72
  209. data/lib/selenium/webdriver/devtools/v88/console.rb +0 -59
  210. data/lib/selenium/webdriver/devtools/v88/css.rb +0 -181
  211. data/lib/selenium/webdriver/devtools/v88/database.rb +0 -66
  212. data/lib/selenium/webdriver/devtools/v88/debugger.rb +0 -233
  213. data/lib/selenium/webdriver/devtools/v88/device_orientation.rb +0 -55
  214. data/lib/selenium/webdriver/devtools/v88/dom.rb +0 -329
  215. data/lib/selenium/webdriver/devtools/v88/dom_debugger.rb +0 -95
  216. data/lib/selenium/webdriver/devtools/v88/dom_snapshot.rb +0 -67
  217. data/lib/selenium/webdriver/devtools/v88/dom_storage.rb +0 -81
  218. data/lib/selenium/webdriver/devtools/v88/emulation.rb +0 -198
  219. data/lib/selenium/webdriver/devtools/v88/fetch.rb +0 -99
  220. data/lib/selenium/webdriver/devtools/v88/headless_experimental.rb +0 -63
  221. data/lib/selenium/webdriver/devtools/v88/heap_profiler.rb +0 -109
  222. data/lib/selenium/webdriver/devtools/v88/indexed_db.rb +0 -102
  223. data/lib/selenium/webdriver/devtools/v88/input.rb +0 -148
  224. data/lib/selenium/webdriver/devtools/v88/inspector.rb +0 -57
  225. data/lib/selenium/webdriver/devtools/v88/io.rb +0 -61
  226. data/lib/selenium/webdriver/devtools/v88/layer_tree.rb +0 -97
  227. data/lib/selenium/webdriver/devtools/v88/log.rb +0 -68
  228. data/lib/selenium/webdriver/devtools/v88/media.rb +0 -59
  229. data/lib/selenium/webdriver/devtools/v88/memory.rb +0 -88
  230. data/lib/selenium/webdriver/devtools/v88/network.rb +0 -247
  231. data/lib/selenium/webdriver/devtools/v88/overlay.rb +0 -183
  232. data/lib/selenium/webdriver/devtools/v88/page.rb +0 -376
  233. data/lib/selenium/webdriver/devtools/v88/performance.rb +0 -65
  234. data/lib/selenium/webdriver/devtools/v88/profiler.rb +0 -125
  235. data/lib/selenium/webdriver/devtools/v88/runtime.rb +0 -197
  236. data/lib/selenium/webdriver/devtools/v88/schema.rb +0 -48
  237. data/lib/selenium/webdriver/devtools/v88/security.rb +0 -73
  238. data/lib/selenium/webdriver/devtools/v88/service_worker.rb +0 -118
  239. data/lib/selenium/webdriver/devtools/v88/storage.rb +0 -103
  240. data/lib/selenium/webdriver/devtools/v88/system_info.rb +0 -52
  241. data/lib/selenium/webdriver/devtools/v88/target.rb +0 -145
  242. data/lib/selenium/webdriver/devtools/v88/tethering.rb +0 -57
  243. data/lib/selenium/webdriver/devtools/v88/tracing.rb +0 -79
  244. data/lib/selenium/webdriver/devtools/v88/web_audio.rb +0 -72
  245. data/lib/selenium/webdriver/devtools/v88/web_authn.rb +0 -102
  246. data/lib/selenium/webdriver/safari/bridge.rb +0 -51
  247. data/selenium_server_deploy.jar +0 -0
@@ -1,3 +1,20 @@
1
+ // Licensed to the Software Freedom Conservancy (SFC) under one
2
+ // or more contributor license agreements. See the NOTICE file
3
+ // distributed with this work for additional information
4
+ // regarding copyright ownership. The SFC licenses this file
5
+ // to you under the Apache License, Version 2.0 (the
6
+ // "License"); you may not use this file except in compliance
7
+ // with the License. You may obtain a copy of the License at
8
+ //
9
+ // http://www.apache.org/licenses/LICENSE-2.0
10
+ //
11
+ // Unless required by applicable law or agreed to in writing,
12
+ // software distributed under the License is distributed on an
13
+ // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ // KIND, either express or implied. See the License for the
15
+ // specific language governing permissions and limitations
16
+ // under the License.
17
+
1
18
  (function () {
2
19
  const observer = new MutationObserver((mutations) => {
3
20
  for (const mutation of mutations) {
@@ -27,37 +27,40 @@ module Selenium
27
27
  #
28
28
 
29
29
  class Driver < WebDriver::Driver
30
- include DriverExtensions::HasNetworkConditions
31
- include DriverExtensions::HasWebStorage
32
- include DriverExtensions::HasLocation
33
- include DriverExtensions::DownloadsFiles
34
- include DriverExtensions::HasDevTools
35
- include DriverExtensions::HasAuthentication
36
- include DriverExtensions::HasLogs
37
- include DriverExtensions::HasLogEvents
38
- include DriverExtensions::PrintsPage
30
+ EXTENSIONS = [DriverExtensions::HasCDP,
31
+ DriverExtensions::HasNetworkConditions,
32
+ DriverExtensions::HasNetworkInterception,
33
+ DriverExtensions::HasWebStorage,
34
+ DriverExtensions::HasLocation,
35
+ DriverExtensions::DownloadsFiles,
36
+ DriverExtensions::HasDevTools,
37
+ DriverExtensions::HasAuthentication,
38
+ DriverExtensions::HasLogs,
39
+ DriverExtensions::HasLogEvents,
40
+ DriverExtensions::HasPinnedScripts,
41
+ DriverExtensions::PrintsPage].freeze
39
42
 
40
43
  def browser
41
44
  :chrome
42
45
  end
43
46
 
44
- def bridge_class
45
- Bridge
46
- end
47
+ private
47
48
 
48
- def execute_cdp(cmd, **params)
49
- @bridge.send_command(cmd: cmd, params: params)
50
- end
49
+ def devtools_url
50
+ uri = URI(devtools_address)
51
+ response = Net::HTTP.get(uri.hostname, '/json/version', uri.port)
51
52
 
52
- private
53
+ JSON.parse(response)['webSocketDebuggerUrl']
54
+ end
53
55
 
54
56
  def devtools_version
55
57
  Integer(capabilities.browser_version.split('.').first)
56
58
  end
57
59
 
58
- def debugger_address
59
- capabilities['goog:chromeOptions']['debuggerAddress']
60
+ def devtools_address
61
+ "http://#{capabilities['goog:chromeOptions']['debuggerAddress']}"
60
62
  end
63
+
61
64
  end # Driver
62
65
  end # Chrome
63
66
  end # WebDriver
@@ -230,7 +230,7 @@ module Selenium
230
230
  end
231
231
 
232
232
  def camelize?(key)
233
- !['prefs'].include?(key)
233
+ !%w[localState prefs].include?(key)
234
234
  end
235
235
  end # Options
236
236
  end # Chrome
@@ -27,12 +27,11 @@ module Selenium
27
27
  class Profile
28
28
  include ProfileHelper
29
29
 
30
- attr_reader :directory
31
-
32
30
  def initialize(model = nil)
33
31
  @model = verify_model(model)
34
32
  @extensions = []
35
33
  @encoded_extensions = []
34
+ @directory = nil
36
35
  end
37
36
 
38
37
  def add_extension(path)
@@ -45,6 +44,10 @@ module Selenium
45
44
  @encoded_extensions << encoded
46
45
  end
47
46
 
47
+ def directory
48
+ @directory || layout_on_disk
49
+ end
50
+
48
51
  #
49
52
  # Set a preference in the profile.
50
53
  #
@@ -39,7 +39,9 @@ module Selenium
39
39
  driver_args << "--log-path=#{driver_opts.delete(:log_path)}" if driver_opts.key?(:log_path)
40
40
  driver_args << "--url-base=#{driver_opts.delete(:url_base)}" if driver_opts.key?(:url_base)
41
41
  driver_args << "--port-server=#{driver_opts.delete(:port_server)}" if driver_opts.key?(:port_server)
42
- driver_args << "--whitelisted-ips=#{driver_opts.delete(:whitelisted_ips)}" if driver_opts.key?(:whitelisted_ips)
42
+ if driver_opts.key?(:whitelisted_ips)
43
+ driver_args << "--whitelisted-ips=#{driver_opts.delete(:whitelisted_ips)}"
44
+ end
43
45
  driver_args << "--verbose" if driver_opts.key?(:verbose)
44
46
  driver_args << "--silent" if driver_opts.key?(:silent)
45
47
  driver_args
@@ -22,7 +22,7 @@ require 'net/http'
22
22
  module Selenium
23
23
  module WebDriver
24
24
  module Chrome
25
- autoload :Bridge, 'selenium/webdriver/chrome/bridge'
25
+ autoload :Features, 'selenium/webdriver/chrome/features'
26
26
  autoload :Driver, 'selenium/webdriver/chrome/driver'
27
27
  autoload :Profile, 'selenium/webdriver/chrome/profile'
28
28
  autoload :Options, 'selenium/webdriver/chrome/options'
@@ -71,11 +71,13 @@ module Selenium
71
71
  def initialize(bridge: nil, listener: nil, **opts)
72
72
  @service = nil
73
73
  bridge ||= create_bridge(**opts)
74
+ add_extensions(bridge.browser)
74
75
  @bridge = listener ? Support::EventFiringBridge.new(bridge, listener) : bridge
75
76
  end
76
77
 
77
78
  def inspect
78
- format '#<%<class>s:0x%<hash>x browser=%<browser>s>', class: self.class, hash: hash * 2, browser: bridge.browser.inspect
79
+ format '#<%<class>s:0x%<hash>x browser=%<browser>s>', class: self.class, hash: hash * 2,
80
+ browser: bridge.browser.inspect
79
81
  end
80
82
 
81
83
  #
@@ -295,7 +297,9 @@ module Selenium
295
297
  # @see SearchContext
296
298
  #
297
299
 
298
- def ref; end
300
+ def ref
301
+ [:driver, nil]
302
+ end
299
303
 
300
304
  private
301
305
 
@@ -329,7 +333,7 @@ module Selenium
329
333
  bridge_opts = {http_client: opts.delete(:http_client), url: opts.delete(:url)}
330
334
  raise ArgumentError, "Unable to create a driver with parameters: #{opts}" unless opts.empty?
331
335
 
332
- bridge = (respond_to?(:bridge_class) ? bridge_class : Remote::Bridge).new(**bridge_opts)
336
+ bridge = Remote::Bridge.new(**bridge_opts)
333
337
 
334
338
  bridge.create_session(capabilities)
335
339
  bridge
@@ -340,8 +344,9 @@ module Selenium
340
344
  if cap.is_a? Symbol
341
345
  cap = Remote::Capabilities.send(cap)
342
346
  elsif cap.is_a? Hash
347
+ new_message = 'Capabilities instance initialized with the Hash, or build values with Options class'
343
348
  WebDriver.logger.deprecate("passing a Hash value to :capabilities",
344
- 'Capabilities instance initialized with the Hash, or build values with Options class',
349
+ new_message,
345
350
  id: :capabilities_hash)
346
351
  cap = Remote::Capabilities.new(cap)
347
352
  elsif !cap.respond_to? :as_json
@@ -371,6 +376,20 @@ module Selenium
371
376
  def screenshot
372
377
  bridge.screenshot
373
378
  end
379
+
380
+ def add_extensions(browser)
381
+ extensions = case browser
382
+ when :chrome, :msedge
383
+ Chrome::Driver::EXTENSIONS
384
+ when :firefox
385
+ Firefox::Driver::EXTENSIONS
386
+ when :safari, :safari_technology_preview
387
+ Safari::Driver::EXTENSIONS
388
+ else
389
+ []
390
+ end
391
+ extensions.each { |extension| extend extension }
392
+ end
374
393
  end # Driver
375
394
  end # WebDriver
376
395
  end # Selenium
@@ -17,32 +17,27 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- # This file is automatically generated. Any changes will be lost!
21
20
  module Selenium
22
21
  module WebDriver
23
- class DevTools
24
- def schema
25
- @schema ||= V87::Schema.new(self)
26
- end
22
+ module DriverExtensions
23
+ module FullPageScreenshot
24
+ #
25
+ # Save a PNG screenshot of the full page to the given path
26
+ #
27
+ # @api public
28
+ #
27
29
 
28
- module V87
29
- class Schema
30
+ def save_full_page_screenshot(path)
31
+ save_screenshot(path, full_page: true)
32
+ end
30
33
 
31
- def initialize(devtools)
32
- @devtools = devtools
33
- end
34
+ private
34
35
 
35
- def on(event, &block)
36
- event = EVENTS[event] if event.is_a?(Symbol)
37
- @devtools.callbacks["Schema.#{event}"] << block
38
- end
36
+ def full_screenshot
37
+ @bridge.full_screenshot
38
+ end
39
39
 
40
- def get_domains
41
- @devtools.send_cmd('Schema.getDomains')
42
- end
43
-
44
- end # V87
45
- end # Schema
46
- end # DevTools
40
+ end # FullPageScreenshot
41
+ end # DriverExtensions
47
42
  end # WebDriver
48
43
  end # Selenium
@@ -17,21 +17,22 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- require 'selenium/webdriver/chrome/bridge'
21
-
22
20
  module Selenium
23
21
  module WebDriver
24
- module Edge
25
- class Bridge < WebDriver::Chrome::Bridge
22
+ module DriverExtensions
23
+ module HasCDP
26
24
 
27
- COMMANDS = WebDriver::Chrome::Bridge::COMMANDS.merge(
28
- send_command: [:post, 'session/:session_id/ms/cdp/execute']
29
- ).freeze
25
+ #
26
+ # Returns network conditions.
27
+ #
28
+ # @return [Hash]
29
+ #
30
30
 
31
- def commands(command)
32
- COMMANDS[command] || super
31
+ def execute_cdp(cmd, **params)
32
+ @bridge.send_command(cmd: cmd, params: params)
33
33
  end
34
- end # Bridge
35
- end # Edge
34
+
35
+ end # HasCDP
36
+ end # DriverExtensions
36
37
  end # WebDriver
37
38
  end # Selenium
@@ -29,7 +29,12 @@ module Selenium
29
29
  #
30
30
 
31
31
  def devtools
32
- @devtools ||= DevTools.new(url: debugger_address, version: devtools_version)
32
+ @devtools ||= begin
33
+ require 'selenium/devtools'
34
+ Selenium::DevTools.version ||= devtools_version
35
+ Selenium::DevTools.load_version
36
+ Selenium::WebDriver::DevTools.new(url: devtools_url)
37
+ end
33
38
  end
34
39
 
35
40
  end # HasDevTools
@@ -112,8 +112,7 @@ module Selenium
112
112
 
113
113
  devtools.runtime.add_binding(name: '__webdriver_attribute')
114
114
  execute_script(mutation_listener)
115
- script = devtools.page.add_script_to_evaluate_on_new_document(source: mutation_listener)
116
- pinned_scripts[mutation_listener] = script['identifier']
115
+ devtools.page.add_script_to_evaluate_on_new_document(source: mutation_listener)
117
116
 
118
117
  devtools.runtime.on(:binding_called, &method(:log_mutation_event))
119
118
  end
@@ -139,10 +138,6 @@ module Selenium
139
138
  @mutation_listener ||= read_atom(:mutationListener)
140
139
  end
141
140
 
142
- def pinned_scripts
143
- @pinned_scripts ||= {}
144
- end
145
-
146
141
  end # HasLogEvents
147
142
  end # DriverExtensions
148
143
  end # WebDriver
@@ -23,11 +23,13 @@ module Selenium
23
23
  module DriverExtensions
24
24
  module HasNetworkConnection
25
25
  def network_connection_type
26
- raise Error::UnsupportedOperationError, 'The W3C standard does not currently support getting network connection'
26
+ raise Error::UnsupportedOperationError,
27
+ 'The W3C standard does not currently support getting network connection'
27
28
  end
28
29
 
29
30
  def network_connection_type=(*)
30
- raise Error::UnsupportedOperationError, 'The W3C standard does not currently support setting network connection'
31
+ raise Error::UnsupportedOperationError,
32
+ 'The W3C standard does not currently support setting network connection'
31
33
  end
32
34
  end # HasNetworkConnection
33
35
  end # DriverExtensions
@@ -0,0 +1,67 @@
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 DriverExtensions
23
+ module HasNetworkInterception
24
+
25
+ #
26
+ # Intercepts requests coming from browser allowing
27
+ # to either pass them through like proxy or provide
28
+ # a stubbed response instead.
29
+ #
30
+ # @example Log requests and pass through
31
+ # driver.intercept do |request|
32
+ # puts "#{request.method} #{request.url}"
33
+ # request.continue
34
+ # end
35
+ #
36
+ # @example Stub response for image requests
37
+ # driver.intercept do |request|
38
+ # if request.url.match?(/\.png$/)
39
+ # request.respond(body: File.read('myfile.png'))
40
+ # else
41
+ # request.continue
42
+ # end
43
+ # end
44
+ #
45
+ # @param [#call] block which is called when request is interecepted
46
+ # @yieldparam [DevTools::Request]
47
+ #
48
+
49
+ def intercept
50
+ devtools.network.set_cache_disabled(cache_disabled: true)
51
+ devtools.fetch.on(:request_paused) do |params|
52
+ request = DevTools::Request.new(
53
+ devtools: devtools,
54
+ id: params['requestId'],
55
+ url: params.dig('request', 'url'),
56
+ method: params.dig('request', 'method'),
57
+ headers: params.dig('request', 'headers')
58
+ )
59
+ yield request
60
+ end
61
+ devtools.fetch.enable
62
+ end
63
+
64
+ end # HasNetworkInterception
65
+ end # DriverExtensions
66
+ end # WebDriver
67
+ end # Selenium
@@ -0,0 +1,77 @@
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 DriverExtensions
23
+ module HasPinnedScripts
24
+
25
+ #
26
+ # Returns the list of all pinned scripts.
27
+ #
28
+ # @return [Array<DevTools::PinnedScript>]
29
+ #
30
+
31
+ def pinned_scripts
32
+ @pinned_scripts ||= []
33
+ end
34
+
35
+ #
36
+ # Pins JavaScript snippet that is available during the whole
37
+ # session on every page. This allows to store and call
38
+ # scripts without sending them over the wire every time.
39
+ #
40
+ # @example
41
+ # script = driver.pin_script('return window.location.href')
42
+ # driver.execute_script(script)
43
+ # # navigate to a new page
44
+ # driver.execute_script(script)
45
+ #
46
+ # @param [String] script
47
+ # @return [DevTools::PinnedScript]
48
+ #
49
+
50
+ def pin_script(script)
51
+ script = DevTools::PinnedScript.new(script)
52
+ pinned_scripts << script
53
+
54
+ devtools.page.enable
55
+ devtools.runtime.evaluate(expression: script.callable)
56
+ response = devtools.page.add_script_to_evaluate_on_new_document(source: script.callable)
57
+ script.devtools_identifier = response.dig('result', 'identifier')
58
+
59
+ script
60
+ end
61
+
62
+ #
63
+ # Unpins script making it undefined for the subsequent calls.
64
+ #
65
+ # @param [DevTools::PinnedScript]
66
+ #
67
+
68
+ def unpin_script(script)
69
+ devtools.runtime.evaluate(expression: script.remove)
70
+ devtools.page.remove_script_to_evaluate_on_new_document(identifier: script.devtools_identifier)
71
+ pinned_scripts.delete(script)
72
+ end
73
+
74
+ end # HasPinnedScripts
75
+ end # DriverExtensions
76
+ end # WebDriver
77
+ end # Selenium