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
@@ -24,7 +24,8 @@ module Selenium
24
24
 
25
25
  FIREFOX_COMMANDS = {
26
26
  install_addon: [:post, 'session/:session_id/moz/addon/install'],
27
- uninstall_addon: [:post, 'session/:session_id/moz/addon/uninstall']
27
+ uninstall_addon: [:post, 'session/:session_id/moz/addon/uninstall'],
28
+ full_page_screenshot: [:get, 'session/:session_id/moz/screenshot/full']
28
29
  }.freeze
29
30
 
30
31
  def commands(command)
@@ -41,6 +42,10 @@ module Selenium
41
42
  execute :uninstall_addon, {}, {id: id}
42
43
  end
43
44
 
45
+ def full_screenshot
46
+ execute :full_page_screenshot
47
+ end
48
+
44
49
  end # Bridge
45
50
  end # Firefox
46
51
  end # WebDriver
@@ -27,7 +27,7 @@ module Selenium
27
27
  autoload :Extension, 'selenium/webdriver/firefox/extension'
28
28
  autoload :ProfilesIni, 'selenium/webdriver/firefox/profiles_ini'
29
29
  autoload :Profile, 'selenium/webdriver/firefox/profile'
30
- autoload :Bridge, 'selenium/webdriver/firefox/bridge'
30
+ autoload :Features, 'selenium/webdriver/firefox/features'
31
31
  autoload :Driver, 'selenium/webdriver/firefox/driver'
32
32
  autoload :Options, 'selenium/webdriver/firefox/options'
33
33
  autoload :Service, 'selenium/webdriver/firefox/service'
@@ -38,6 +38,10 @@ module Selenium
38
38
  DEFAULT_ASSUME_UNTRUSTED_ISSUER = true
39
39
  DEFAULT_LOAD_NO_FOCUS_LIB = false
40
40
 
41
+ # Mozilla Automation Team asked to only support 85
42
+ # until WebDriver Bidi is available.
43
+ DEVTOOLS_VERSION = 85
44
+
41
45
  def self.driver_path=(path)
42
46
  WebDriver.logger.deprecate 'Selenium::WebDriver::Firefox#driver_path=',
43
47
  'Selenium::WebDriver::Firefox::Service#driver_path=',
@@ -28,7 +28,7 @@ module Selenium
28
28
  #
29
29
 
30
30
  class Driver < WebDriver::Driver
31
- include DriverExtensions::HasWebStorage
31
+ EXTENSIONS = [DriverExtensions::HasWebStorage].freeze
32
32
 
33
33
  def browser
34
34
  :internet_explorer
@@ -39,7 +39,9 @@ module Selenium
39
39
  persistent_hover: 'enablePersistentHover',
40
40
  require_window_focus: 'requireWindowFocus',
41
41
  use_per_process_proxy: 'ie.usePerProcessProxy',
42
- validate_cookie_document_type: 'ie.validateCookieDocumentType'
42
+ use_legacy_file_upload_dialog_handling: 'ie.useLegacyFileUploadDialogHandling',
43
+ attach_to_edge_chrome: 'ie.edgechromium',
44
+ edge_executable_path: 'ie.edgepath'
43
45
  }.freeze
44
46
  BROWSER = 'internet explorer'
45
47
 
@@ -25,7 +25,7 @@ module Selenium
25
25
  EXECUTABLE = 'IEDriverServer'
26
26
  MISSING_TEXT = <<~ERROR
27
27
  Unable to find IEDriverServer. Please download the server from
28
- http://selenium-release.storage.googleapis.com/index.html and place it somewhere on your PATH.
28
+ https://www.selenium.dev/downloads/ and place it somewhere on your PATH.
29
29
  More info at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver.
30
30
  ERROR
31
31
  SHUTDOWN_SUPPORTED = true
@@ -38,7 +38,9 @@ module Selenium
38
38
  driver_opts = driver_opts.dup
39
39
  driver_args << "--log-level=#{driver_opts[:log_level].to_s.upcase}" if driver_opts.key?(:log_level)
40
40
  driver_args << "--log-file=#{driver_opts[:log_file]}" if driver_opts.key?(:log_file)
41
- driver_args << "--implementation=#{driver_opts[:implementation].to_s.upcase}" if driver_opts.key?(:implementation)
41
+ if driver_opts.key?(:implementation)
42
+ driver_args << "--implementation=#{driver_opts[:implementation].to_s.upcase}"
43
+ end
42
44
  driver_args << "--host=#{driver_opts[:host]}" if driver_opts.key?(:host)
43
45
  driver_args << "--extract_path=#{driver_opts[:extract_path]}" if driver_opts.key?(:extract_path)
44
46
  driver_args << "--silent" if driver_opts[:silent] == true
@@ -49,7 +49,7 @@ module Selenium
49
49
  #
50
50
 
51
51
  def create_session(capabilities)
52
- response = execute(:new_session, {}, {capabilities: {firstMatch: [capabilities]}})
52
+ response = execute(:new_session, {}, prepare_capabilities_payload(capabilities))
53
53
 
54
54
  @session_id = response['sessionId']
55
55
  capabilities = response['capabilities']
@@ -57,6 +57,17 @@ module Selenium
57
57
  raise Error::WebDriverError, 'no sessionId in returned payload' unless @session_id
58
58
 
59
59
  @capabilities = Capabilities.json_create(capabilities)
60
+
61
+ case @capabilities[:browser_name]
62
+ when 'chrome'
63
+ extend(WebDriver::Chrome::Features)
64
+ when 'firefox'
65
+ extend(WebDriver::Firefox::Features)
66
+ when 'msedge'
67
+ extend(WebDriver::Edge::Features)
68
+ when 'Safari', 'Safari Technology Preview'
69
+ extend(WebDriver::Safari::Features)
70
+ end
60
71
  end
61
72
 
62
73
  #
@@ -70,7 +81,7 @@ module Selenium
70
81
  def browser
71
82
  @browser ||= begin
72
83
  name = @capabilities.browser_name
73
- name ? name.tr(' ', '_').to_sym : 'unknown'
84
+ name ? name.tr(' ', '_').downcase.to_sym : 'unknown'
74
85
  end
75
86
  end
76
87
 
@@ -207,7 +218,10 @@ module Selenium
207
218
  end
208
219
 
209
220
  def window_size(handle = :current)
210
- raise Error::UnsupportedOperationError, 'Switch to desired window before getting its size' unless handle == :current
221
+ unless handle == :current
222
+ raise Error::UnsupportedOperationError,
223
+ 'Switch to desired window before getting its size'
224
+ end
211
225
 
212
226
  data = execute :get_window_rect
213
227
  Dimension.new data['width'], data['height']
@@ -218,7 +232,10 @@ module Selenium
218
232
  end
219
233
 
220
234
  def maximize_window(handle = :current)
221
- raise Error::UnsupportedOperationError, 'Switch to desired window before changing its size' unless handle == :current
235
+ unless handle == :current
236
+ raise Error::UnsupportedOperationError,
237
+ 'Switch to desired window before changing its size'
238
+ end
222
239
 
223
240
  execute :maximize_window
224
241
  end
@@ -252,7 +269,7 @@ module Selenium
252
269
  end
253
270
 
254
271
  def element_screenshot(element)
255
- execute :take_element_screenshot, id: element.ref
272
+ execute :take_element_screenshot, id: element
256
273
  end
257
274
 
258
275
  #
@@ -414,7 +431,7 @@ module Selenium
414
431
  end
415
432
 
416
433
  def submit_element(element)
417
- form = find_element_by('xpath', "./ancestor-or-self::form", element)
434
+ form = find_element_by('xpath', "./ancestor-or-self::form", [:element, element])
418
435
  execute_script("var e = arguments[0].ownerDocument.createEvent('Event');" \
419
436
  "e.initEvent('submit', true, true);" \
420
437
  'if (arguments[0].dispatchEvent(e)) { arguments[0].submit() }', form.as_json)
@@ -433,8 +450,20 @@ module Selenium
433
450
  execute_atom :getAttribute, element, name
434
451
  end
435
452
 
453
+ def element_dom_attribute(element, name)
454
+ execute :get_element_attribute, id: element, name: name
455
+ end
456
+
436
457
  def element_property(element, name)
437
- execute :get_element_property, id: element.ref, name: name
458
+ execute :get_element_property, id: element, name: name
459
+ end
460
+
461
+ def element_aria_role(element)
462
+ execute :get_element_aria_role, id: element
463
+ end
464
+
465
+ def element_aria_label(element)
466
+ execute :get_element_aria_label, id: element
438
467
  end
439
468
 
440
469
  def element_value(element)
@@ -495,13 +524,17 @@ module Selenium
495
524
 
496
525
  alias_method :switch_to_active_element, :active_element
497
526
 
498
- def find_element_by(how, what, parent = nil)
527
+ def find_element_by(how, what, parent_ref = [])
499
528
  how, what = convert_locator(how, what)
500
529
 
501
530
  return execute_atom(:findElements, Support::RelativeLocator.new(what).as_json).first if how == 'relative'
502
531
 
503
- id = if parent
504
- execute :find_child_element, {id: parent}, {using: how, value: what.to_s}
532
+ parent_type, parent_id = parent_ref
533
+ id = case parent_type
534
+ when :element
535
+ execute :find_child_element, {id: parent_id}, {using: how, value: what.to_s}
536
+ when :shadow_root
537
+ execute :find_shadow_child_element, {id: parent_id}, {using: how, value: what.to_s}
505
538
  else
506
539
  execute :find_element, {}, {using: how, value: what.to_s}
507
540
  end
@@ -509,13 +542,17 @@ module Selenium
509
542
  Element.new self, element_id_from(id)
510
543
  end
511
544
 
512
- def find_elements_by(how, what, parent = nil)
545
+ def find_elements_by(how, what, parent_ref = [])
513
546
  how, what = convert_locator(how, what)
514
547
 
515
548
  return execute_atom :findElements, Support::RelativeLocator.new(what).as_json if how == 'relative'
516
549
 
517
- ids = if parent
518
- execute :find_child_elements, {id: parent}, {using: how, value: what.to_s}
550
+ parent_type, parent_id = parent_ref
551
+ ids = case parent_type
552
+ when :element
553
+ execute :find_child_elements, {id: parent_id}, {using: how, value: what.to_s}
554
+ when :shadow_root
555
+ execute :find_shadow_child_elements, {id: parent_id}, {using: how, value: what.to_s}
519
556
  else
520
557
  execute :find_elements, {}, {using: how, value: what.to_s}
521
558
  end
@@ -523,6 +560,11 @@ module Selenium
523
560
  ids.map { |id| Element.new self, element_id_from(id) }
524
561
  end
525
562
 
563
+ def shadow_root(element)
564
+ id = execute :get_element_shadow_root, id: element
565
+ ShadowRoot.new self, shadow_root_id_from(id)
566
+ end
567
+
526
568
  private
527
569
 
528
570
  #
@@ -570,7 +612,16 @@ module Selenium
570
612
  end
571
613
 
572
614
  def element_id_from(id)
573
- id['ELEMENT'] || id['element-6066-11e4-a52e-4f735466cecf']
615
+ id['ELEMENT'] || id[Element::ELEMENT_KEY]
616
+ end
617
+
618
+ def shadow_root_id_from(id)
619
+ id[ShadowRoot::ROOT_KEY]
620
+ end
621
+
622
+ def prepare_capabilities_payload(capabilities)
623
+ capabilities = {alwaysMatch: capabilities} if !capabilities['alwaysMatch'] && !capabilities['firstMatch']
624
+ {capabilities: capabilities}
574
625
  end
575
626
 
576
627
  def convert_locator(how, what)
@@ -40,22 +40,15 @@ module Selenium
40
40
  :unhandled_prompt_behavior,
41
41
  :strict_file_interactability,
42
42
 
43
- # remote-specific
44
- :remote_session_id,
45
-
46
- # TODO: (AR) deprecate compatibility with OSS-capabilities
47
- :implicit_timeout,
48
- :page_load_timeout,
49
- :script_timeout
43
+ # remote-specific (webdriver.remote.sessionid)
44
+ :remote_session_id
50
45
  ].freeze
51
46
 
52
- KNOWN.each do |key|
47
+ (KNOWN - %i[proxy timeouts]).each do |key|
53
48
  define_method key do
54
- @capabilities.fetch(key)
49
+ @capabilities[key]
55
50
  end
56
51
 
57
- next if key == :proxy
58
-
59
52
  define_method "#{key}=" do |value|
60
53
  @capabilities[key] = value
61
54
  end
@@ -86,18 +79,13 @@ module Selenium
86
79
  browser_name: 'MicrosoftEdge'
87
80
  }.merge(opts))
88
81
  end
82
+ alias_method :microsoftedge, :edge
89
83
 
90
84
  def firefox(opts = {})
91
- opts[:browser_version] = opts.delete(:version) if opts.key?(:version)
92
- opts[:platform_name] = opts.delete(:platform) if opts.key?(:platform)
93
- opts[:timeouts] = {}
94
- opts[:timeouts]['implicit'] = opts.delete(:implicit_timeout) if opts.key?(:implicit_timeout)
95
- opts[:timeouts]['pageLoad'] = opts.delete(:page_load_timeout) if opts.key?(:page_load_timeout)
96
- opts[:timeouts]['script'] = opts.delete(:script_timeout) if opts.key?(:script_timeout)
97
- opts.delete(:timeouts) if opts[:timeouts].empty?
98
- new({browser_name: 'firefox'}.merge(opts))
85
+ new({
86
+ browser_name: 'firefox'
87
+ }.merge(opts))
99
88
  end
100
-
101
89
  alias_method :ff, :firefox
102
90
 
103
91
  def safari(opts = {})
@@ -120,19 +108,21 @@ module Selenium
120
108
  end
121
109
  alias_method :ie, :internet_explorer
122
110
 
111
+ def always_match(capabilities)
112
+ new(always_match: capabilities)
113
+ end
114
+
115
+ def first_match(*capabilities)
116
+ new(first_match: capabilities)
117
+ end
118
+
123
119
  #
124
120
  # @api private
125
121
  #
126
122
 
127
123
  def json_create(data)
128
124
  data = data.dup
129
-
130
125
  caps = new
131
- caps.browser_name = data.delete('browserName') if data.key?('browserName')
132
- caps.browser_version = data.delete('browserVersion') if data.key?('browserVersion')
133
- caps.platform_name = data.delete('platformName') if data.key?('platformName')
134
- caps.accept_insecure_certs = data.delete('acceptInsecureCerts') if data.key?('acceptInsecureCerts')
135
- caps.page_load_strategy = data.delete('pageLoadStrategy') if data.key?('pageLoadStrategy')
136
126
 
137
127
  process_timeouts(caps, data.delete('timeouts'))
138
128
 
@@ -142,7 +132,14 @@ module Selenium
142
132
  end
143
133
 
144
134
  # Remote Server Specific
145
- caps[:remote_session_id] = data.delete('webdriver.remote.sessionid') if data.key?('webdriver.remote.sessionid')
135
+ if data.key?('webdriver.remote.sessionid')
136
+ caps[:remote_session_id] = data.delete('webdriver.remote.sessionid')
137
+ end
138
+
139
+ KNOWN.each do |cap|
140
+ data_value = camel_case(cap)
141
+ caps[cap] = data.delete(data_value) if data.key?(data_value)
142
+ end
146
143
 
147
144
  # any remaining pairs will be added as is, with no conversion
148
145
  caps.merge!(data)
@@ -150,6 +147,10 @@ module Selenium
150
147
  caps
151
148
  end
152
149
 
150
+ def camel_case(str_or_sym)
151
+ str_or_sym.to_s.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
152
+ end
153
+
153
154
  private
154
155
 
155
156
  def process_timeouts(caps, timeouts)
@@ -173,8 +174,9 @@ module Selenium
173
174
  #
174
175
 
175
176
  def initialize(opts = {})
176
- @capabilities = opts
177
- self.proxy = opts.delete(:proxy)
177
+ @capabilities = {}
178
+ self.proxy = opts.delete(:proxy) if opts[:proxy]
179
+ @capabilities.merge!(opts)
178
180
  end
179
181
 
180
182
  #
@@ -199,6 +201,10 @@ module Selenium
199
201
  end
200
202
  end
201
203
 
204
+ def proxy
205
+ @capabilities[:proxy]
206
+ end
207
+
202
208
  def proxy=(proxy)
203
209
  case proxy
204
210
  when Hash
@@ -210,33 +216,46 @@ module Selenium
210
216
  end
211
217
  end
212
218
 
219
+ def timeouts
220
+ @capabilities[:timeouts] ||= {}
221
+ end
222
+
223
+ def timeouts=(timeouts)
224
+ @capabilities[:timeouts] = timeouts
225
+ end
226
+
227
+ def implicit_timeout
228
+ timeouts[:implicit]
229
+ end
230
+
231
+ def implicit_timeout=(timeout)
232
+ timeouts[:implicit] = timeout
233
+ end
234
+
235
+ def page_load_timeout
236
+ timeouts[:page_load] || timeouts[:pageLoad]
237
+ end
238
+
239
+ def page_load_timeout=(timeout)
240
+ timeouts[:page_load] = timeout
241
+ end
242
+
243
+ def script_timeout
244
+ timeouts[:script]
245
+ end
246
+
247
+ def script_timeout=(timeout)
248
+ timeouts[:script] = timeout
249
+ end
250
+
213
251
  #
214
252
  # @api private
215
253
  #
216
254
 
217
255
  def as_json(*)
218
- hash = {}
219
-
220
- @capabilities.each do |key, value|
221
- case key
222
- when :platform
223
- hash['platform'] = value.to_s.upcase
224
- when :proxy
225
- if value
226
- hash['proxy'] = value.as_json
227
- hash['proxy']['proxyType'] &&= hash['proxy']['proxyType'].downcase
228
- hash['proxy']['noProxy'] = hash['proxy']['noProxy'].split(', ') if hash['proxy']['noProxy'].is_a?(String)
229
- end
230
- when String
231
- hash[key.to_s] = value
232
- when Symbol
233
- hash[camel_case(key.to_s)] = value
234
- else
235
- raise TypeError, "expected String or Symbol, got #{key.inspect}:#{key.class} / #{value.inspect}"
236
- end
256
+ @capabilities.each_with_object({}) do |(key, value), hash|
257
+ hash[convert_key(key)] = process_capabilities(key, value, hash)
237
258
  end
238
-
239
- hash
240
259
  end
241
260
 
242
261
  def to_json(*)
@@ -257,10 +276,44 @@ module Selenium
257
276
 
258
277
  private
259
278
 
260
- def camel_case(str)
261
- str.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
279
+ def process_capabilities(key, value, hash)
280
+ case value
281
+ when Array
282
+ value.map { |v| process_capabilities(key, v, hash) }
283
+ when Hash
284
+ value.each_with_object({}) do |(k, v), h|
285
+ h[convert_key(k)] = process_capabilities(k, v, h)
286
+ end
287
+ when Capabilities, Options
288
+ value.as_json
289
+ else
290
+ convert_value(key, value)
291
+ end
262
292
  end
263
293
 
294
+ def convert_key(key)
295
+ case key
296
+ when String
297
+ key.to_s
298
+ when Symbol
299
+ self.class.camel_case(key)
300
+ else
301
+ raise TypeError, "expected String or Symbol, got #{key.inspect}:#{key.class}"
302
+ end
303
+ end
304
+
305
+ def convert_value(key, value)
306
+ case key
307
+ when :platform
308
+ value.to_s.upcase
309
+ when :proxy
310
+ value&.as_json
311
+ when :unhandled_prompt_behavior
312
+ value.is_a?(Symbol) ? value.to_s.tr('_', ' ') : value
313
+ else
314
+ value
315
+ end
316
+ end
264
317
  end # Capabilities
265
318
  end # Remote
266
319
  end # WebDriver