selenium-webdriver 4.0.0.alpha2 → 4.0.0.alpha7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES +172 -4
  3. data/LICENSE +1 -1
  4. data/lib/selenium/server.rb +25 -9
  5. data/lib/selenium/webdriver.rb +12 -8
  6. data/lib/selenium/webdriver/atoms/findElements.js +121 -0
  7. data/lib/selenium/webdriver/atoms/getAttribute.js +104 -7
  8. data/lib/selenium/webdriver/atoms/isDisplayed.js +76 -78
  9. data/lib/selenium/webdriver/atoms/mutationListener.js +38 -0
  10. data/lib/selenium/webdriver/chrome.rb +10 -9
  11. data/lib/selenium/webdriver/chrome/bridge.rb +20 -4
  12. data/lib/selenium/webdriver/chrome/driver.rb +7 -49
  13. data/lib/selenium/webdriver/chrome/options.rb +97 -57
  14. data/lib/selenium/webdriver/chrome/profile.rb +3 -3
  15. data/lib/selenium/webdriver/chrome/service.rb +0 -4
  16. data/lib/selenium/webdriver/common.rb +6 -1
  17. data/lib/selenium/webdriver/common/driver.rb +81 -17
  18. data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +89 -0
  19. data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +39 -0
  20. data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +143 -0
  21. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +2 -1
  22. data/lib/selenium/webdriver/common/element.rb +5 -0
  23. data/lib/selenium/webdriver/common/logger.rb +48 -16
  24. data/lib/selenium/webdriver/common/manager.rb +5 -0
  25. data/lib/selenium/webdriver/common/options.rb +116 -0
  26. data/lib/selenium/webdriver/common/platform.rb +4 -1
  27. data/lib/selenium/webdriver/common/port_prober.rb +4 -6
  28. data/lib/selenium/webdriver/common/profile_helper.rb +10 -2
  29. data/lib/selenium/webdriver/common/proxy.rb +0 -0
  30. data/lib/selenium/webdriver/common/search_context.rb +3 -2
  31. data/lib/selenium/webdriver/common/service.rb +30 -113
  32. data/lib/selenium/webdriver/common/service_manager.rb +151 -0
  33. data/lib/selenium/webdriver/common/socket_lock.rb +2 -2
  34. data/lib/selenium/webdriver/common/takes_screenshot.rb +63 -0
  35. data/lib/selenium/webdriver/common/wait.rb +1 -1
  36. data/lib/selenium/webdriver/devtools.rb +132 -0
  37. data/lib/selenium/webdriver/devtools/console_event.rb +38 -0
  38. data/lib/selenium/webdriver/devtools/exception_event.rb +36 -0
  39. data/lib/selenium/webdriver/devtools/mutation_event.rb +37 -0
  40. data/lib/selenium/webdriver/devtools/v84/accessibility.rb +64 -0
  41. data/lib/selenium/webdriver/devtools/v84/animation.rb +100 -0
  42. data/lib/selenium/webdriver/devtools/v84/application_cache.rb +66 -0
  43. data/lib/selenium/webdriver/devtools/v84/audits.rb +63 -0
  44. data/lib/selenium/webdriver/devtools/v84/background_service.rb +69 -0
  45. data/lib/selenium/webdriver/devtools/v84/browser.rb +125 -0
  46. data/lib/selenium/webdriver/devtools/v84/cache_storage.rb +75 -0
  47. data/lib/selenium/webdriver/devtools/v84/cast.rb +72 -0
  48. data/lib/selenium/webdriver/devtools/v84/console.rb +59 -0
  49. data/lib/selenium/webdriver/devtools/v84/css.rb +167 -0
  50. data/lib/selenium/webdriver/devtools/v84/database.rb +66 -0
  51. data/lib/selenium/webdriver/devtools/v84/debugger.rb +231 -0
  52. data/lib/selenium/webdriver/devtools/v84/device_orientation.rb +55 -0
  53. data/lib/selenium/webdriver/devtools/v84/dom.rb +322 -0
  54. data/lib/selenium/webdriver/devtools/v84/dom_debugger.rb +95 -0
  55. data/lib/selenium/webdriver/devtools/v84/dom_snapshot.rb +67 -0
  56. data/lib/selenium/webdriver/devtools/v84/dom_storage.rb +81 -0
  57. data/lib/selenium/webdriver/devtools/v84/emulation.rb +182 -0
  58. data/lib/selenium/webdriver/devtools/v84/fetch.rb +99 -0
  59. data/lib/selenium/webdriver/devtools/v84/headless_experimental.rb +63 -0
  60. data/lib/selenium/webdriver/devtools/v84/heap_profiler.rb +109 -0
  61. data/lib/selenium/webdriver/devtools/v84/indexed_db.rb +102 -0
  62. data/lib/selenium/webdriver/devtools/v84/input.rb +142 -0
  63. data/lib/selenium/webdriver/devtools/v84/inspector.rb +57 -0
  64. data/lib/selenium/webdriver/devtools/v84/io.rb +61 -0
  65. data/lib/selenium/webdriver/devtools/v84/layer_tree.rb +97 -0
  66. data/lib/selenium/webdriver/devtools/v84/log.rb +68 -0
  67. data/lib/selenium/webdriver/devtools/v84/media.rb +59 -0
  68. data/lib/selenium/webdriver/devtools/v84/memory.rb +88 -0
  69. data/lib/selenium/webdriver/devtools/v84/network.rb +230 -0
  70. data/lib/selenium/webdriver/devtools/v84/overlay.rb +159 -0
  71. data/lib/selenium/webdriver/devtools/v84/page.rb +376 -0
  72. data/lib/selenium/webdriver/devtools/v84/performance.rb +65 -0
  73. data/lib/selenium/webdriver/devtools/v84/profiler.rb +113 -0
  74. data/lib/selenium/webdriver/devtools/v84/runtime.rb +195 -0
  75. data/lib/selenium/webdriver/devtools/v84/schema.rb +48 -0
  76. data/lib/selenium/webdriver/devtools/v84/security.rb +73 -0
  77. data/lib/selenium/webdriver/devtools/v84/service_worker.rb +118 -0
  78. data/lib/selenium/webdriver/devtools/v84/storage.rb +97 -0
  79. data/lib/selenium/webdriver/devtools/v84/system_info.rb +52 -0
  80. data/lib/selenium/webdriver/devtools/v84/target.rb +143 -0
  81. data/lib/selenium/webdriver/devtools/v84/tethering.rb +57 -0
  82. data/lib/selenium/webdriver/devtools/v84/tracing.rb +78 -0
  83. data/lib/selenium/webdriver/devtools/v84/web_audio.rb +72 -0
  84. data/lib/selenium/webdriver/devtools/v84/web_authn.rb +96 -0
  85. data/lib/selenium/webdriver/devtools/v85/accessibility.rb +64 -0
  86. data/lib/selenium/webdriver/devtools/v85/animation.rb +100 -0
  87. data/lib/selenium/webdriver/devtools/v85/application_cache.rb +66 -0
  88. data/lib/selenium/webdriver/devtools/v85/audits.rb +63 -0
  89. data/lib/selenium/webdriver/devtools/v85/background_service.rb +69 -0
  90. data/lib/selenium/webdriver/devtools/v85/browser.rb +125 -0
  91. data/lib/selenium/webdriver/devtools/v85/cache_storage.rb +75 -0
  92. data/lib/selenium/webdriver/devtools/v85/cast.rb +72 -0
  93. data/lib/selenium/webdriver/devtools/v85/console.rb +59 -0
  94. data/lib/selenium/webdriver/devtools/v85/css.rb +167 -0
  95. data/lib/selenium/webdriver/devtools/v85/database.rb +66 -0
  96. data/lib/selenium/webdriver/devtools/v85/debugger.rb +231 -0
  97. data/lib/selenium/webdriver/devtools/v85/device_orientation.rb +55 -0
  98. data/lib/selenium/webdriver/devtools/v85/dom.rb +322 -0
  99. data/lib/selenium/webdriver/devtools/v85/dom_debugger.rb +95 -0
  100. data/lib/selenium/webdriver/devtools/v85/dom_snapshot.rb +67 -0
  101. data/lib/selenium/webdriver/devtools/v85/dom_storage.rb +81 -0
  102. data/lib/selenium/webdriver/devtools/v85/emulation.rb +182 -0
  103. data/lib/selenium/webdriver/devtools/v85/fetch.rb +99 -0
  104. data/lib/selenium/webdriver/devtools/v85/headless_experimental.rb +63 -0
  105. data/lib/selenium/webdriver/devtools/v85/heap_profiler.rb +109 -0
  106. data/lib/selenium/webdriver/devtools/v85/indexed_db.rb +102 -0
  107. data/lib/selenium/webdriver/devtools/v85/input.rb +143 -0
  108. data/lib/selenium/webdriver/devtools/v85/inspector.rb +57 -0
  109. data/lib/selenium/webdriver/devtools/v85/io.rb +61 -0
  110. data/lib/selenium/webdriver/devtools/v85/layer_tree.rb +97 -0
  111. data/lib/selenium/webdriver/devtools/v85/log.rb +68 -0
  112. data/lib/selenium/webdriver/devtools/v85/media.rb +59 -0
  113. data/lib/selenium/webdriver/devtools/v85/memory.rb +88 -0
  114. data/lib/selenium/webdriver/devtools/v85/network.rb +230 -0
  115. data/lib/selenium/webdriver/devtools/v85/overlay.rb +160 -0
  116. data/lib/selenium/webdriver/devtools/v85/page.rb +376 -0
  117. data/lib/selenium/webdriver/devtools/v85/performance.rb +65 -0
  118. data/lib/selenium/webdriver/devtools/v85/profiler.rb +113 -0
  119. data/lib/selenium/webdriver/devtools/v85/runtime.rb +196 -0
  120. data/lib/selenium/webdriver/devtools/v85/schema.rb +48 -0
  121. data/lib/selenium/webdriver/devtools/v85/security.rb +73 -0
  122. data/lib/selenium/webdriver/devtools/v85/service_worker.rb +118 -0
  123. data/lib/selenium/webdriver/devtools/v85/storage.rb +97 -0
  124. data/lib/selenium/webdriver/devtools/v85/system_info.rb +52 -0
  125. data/lib/selenium/webdriver/devtools/v85/target.rb +145 -0
  126. data/lib/selenium/webdriver/devtools/v85/tethering.rb +57 -0
  127. data/lib/selenium/webdriver/devtools/v85/tracing.rb +78 -0
  128. data/lib/selenium/webdriver/devtools/v85/web_audio.rb +72 -0
  129. data/lib/selenium/webdriver/devtools/v85/web_authn.rb +96 -0
  130. data/lib/selenium/webdriver/devtools/v86/accessibility.rb +64 -0
  131. data/lib/selenium/webdriver/devtools/v86/animation.rb +100 -0
  132. data/lib/selenium/webdriver/devtools/v86/application_cache.rb +66 -0
  133. data/lib/selenium/webdriver/devtools/v86/audits.rb +63 -0
  134. data/lib/selenium/webdriver/devtools/v86/background_service.rb +69 -0
  135. data/lib/selenium/webdriver/devtools/v86/browser.rb +125 -0
  136. data/lib/selenium/webdriver/devtools/v86/cache_storage.rb +75 -0
  137. data/lib/selenium/webdriver/devtools/v86/cast.rb +72 -0
  138. data/lib/selenium/webdriver/devtools/v86/console.rb +59 -0
  139. data/lib/selenium/webdriver/devtools/v86/css.rb +181 -0
  140. data/lib/selenium/webdriver/devtools/v86/database.rb +66 -0
  141. data/lib/selenium/webdriver/devtools/v86/debugger.rb +233 -0
  142. data/lib/selenium/webdriver/devtools/v86/device_orientation.rb +55 -0
  143. data/lib/selenium/webdriver/devtools/v86/dom.rb +329 -0
  144. data/lib/selenium/webdriver/devtools/v86/dom_debugger.rb +95 -0
  145. data/lib/selenium/webdriver/devtools/v86/dom_snapshot.rb +67 -0
  146. data/lib/selenium/webdriver/devtools/v86/dom_storage.rb +81 -0
  147. data/lib/selenium/webdriver/devtools/v86/emulation.rb +193 -0
  148. data/lib/selenium/webdriver/devtools/v86/fetch.rb +99 -0
  149. data/lib/selenium/webdriver/devtools/v86/headless_experimental.rb +63 -0
  150. data/lib/selenium/webdriver/devtools/v86/heap_profiler.rb +109 -0
  151. data/lib/selenium/webdriver/devtools/v86/indexed_db.rb +102 -0
  152. data/lib/selenium/webdriver/devtools/v86/input.rb +143 -0
  153. data/lib/selenium/webdriver/devtools/v86/inspector.rb +57 -0
  154. data/lib/selenium/webdriver/devtools/v86/io.rb +61 -0
  155. data/lib/selenium/webdriver/devtools/v86/layer_tree.rb +97 -0
  156. data/lib/selenium/webdriver/devtools/v86/log.rb +68 -0
  157. data/lib/selenium/webdriver/devtools/v86/media.rb +59 -0
  158. data/lib/selenium/webdriver/devtools/v86/memory.rb +88 -0
  159. data/lib/selenium/webdriver/devtools/v86/network.rb +235 -0
  160. data/lib/selenium/webdriver/devtools/v86/overlay.rb +183 -0
  161. data/lib/selenium/webdriver/devtools/v86/page.rb +376 -0
  162. data/lib/selenium/webdriver/devtools/v86/performance.rb +65 -0
  163. data/lib/selenium/webdriver/devtools/v86/profiler.rb +113 -0
  164. data/lib/selenium/webdriver/devtools/v86/runtime.rb +196 -0
  165. data/lib/selenium/webdriver/devtools/v86/schema.rb +48 -0
  166. data/lib/selenium/webdriver/devtools/v86/security.rb +73 -0
  167. data/lib/selenium/webdriver/devtools/v86/service_worker.rb +118 -0
  168. data/lib/selenium/webdriver/devtools/v86/storage.rb +97 -0
  169. data/lib/selenium/webdriver/devtools/v86/system_info.rb +52 -0
  170. data/lib/selenium/webdriver/devtools/v86/target.rb +145 -0
  171. data/lib/selenium/webdriver/devtools/v86/tethering.rb +57 -0
  172. data/lib/selenium/webdriver/devtools/v86/tracing.rb +78 -0
  173. data/lib/selenium/webdriver/devtools/v86/web_audio.rb +72 -0
  174. data/lib/selenium/webdriver/devtools/v86/web_authn.rb +102 -0
  175. data/lib/selenium/webdriver/devtools/v87/accessibility.rb +73 -0
  176. data/lib/selenium/webdriver/devtools/v87/animation.rb +100 -0
  177. data/lib/selenium/webdriver/devtools/v87/application_cache.rb +66 -0
  178. data/lib/selenium/webdriver/devtools/v87/audits.rb +63 -0
  179. data/lib/selenium/webdriver/devtools/v87/background_service.rb +69 -0
  180. data/lib/selenium/webdriver/devtools/v87/browser.rb +125 -0
  181. data/lib/selenium/webdriver/devtools/v87/cache_storage.rb +75 -0
  182. data/lib/selenium/webdriver/devtools/v87/cast.rb +72 -0
  183. data/lib/selenium/webdriver/devtools/v87/console.rb +59 -0
  184. data/lib/selenium/webdriver/devtools/v87/css.rb +181 -0
  185. data/lib/selenium/webdriver/devtools/v87/database.rb +66 -0
  186. data/lib/selenium/webdriver/devtools/v87/debugger.rb +233 -0
  187. data/lib/selenium/webdriver/devtools/v87/device_orientation.rb +55 -0
  188. data/lib/selenium/webdriver/devtools/v87/dom.rb +329 -0
  189. data/lib/selenium/webdriver/devtools/v87/dom_debugger.rb +95 -0
  190. data/lib/selenium/webdriver/devtools/v87/dom_snapshot.rb +67 -0
  191. data/lib/selenium/webdriver/devtools/v87/dom_storage.rb +81 -0
  192. data/lib/selenium/webdriver/devtools/v87/emulation.rb +193 -0
  193. data/lib/selenium/webdriver/devtools/v87/fetch.rb +99 -0
  194. data/lib/selenium/webdriver/devtools/v87/headless_experimental.rb +63 -0
  195. data/lib/selenium/webdriver/devtools/v87/heap_profiler.rb +109 -0
  196. data/lib/selenium/webdriver/devtools/v87/indexed_db.rb +102 -0
  197. data/lib/selenium/webdriver/devtools/v87/input.rb +143 -0
  198. data/lib/selenium/webdriver/devtools/v87/inspector.rb +57 -0
  199. data/lib/selenium/webdriver/devtools/v87/io.rb +61 -0
  200. data/lib/selenium/webdriver/devtools/v87/layer_tree.rb +97 -0
  201. data/lib/selenium/webdriver/devtools/v87/log.rb +68 -0
  202. data/lib/selenium/webdriver/devtools/v87/media.rb +59 -0
  203. data/lib/selenium/webdriver/devtools/v87/memory.rb +88 -0
  204. data/lib/selenium/webdriver/devtools/v87/network.rb +247 -0
  205. data/lib/selenium/webdriver/devtools/v87/overlay.rb +183 -0
  206. data/lib/selenium/webdriver/devtools/v87/page.rb +376 -0
  207. data/lib/selenium/webdriver/devtools/v87/performance.rb +65 -0
  208. data/lib/selenium/webdriver/devtools/v87/profiler.rb +125 -0
  209. data/lib/selenium/webdriver/devtools/v87/runtime.rb +196 -0
  210. data/lib/selenium/webdriver/devtools/v87/schema.rb +48 -0
  211. data/lib/selenium/webdriver/devtools/v87/security.rb +73 -0
  212. data/lib/selenium/webdriver/devtools/v87/service_worker.rb +118 -0
  213. data/lib/selenium/webdriver/devtools/v87/storage.rb +97 -0
  214. data/lib/selenium/webdriver/devtools/v87/system_info.rb +52 -0
  215. data/lib/selenium/webdriver/devtools/v87/target.rb +145 -0
  216. data/lib/selenium/webdriver/devtools/v87/tethering.rb +57 -0
  217. data/lib/selenium/webdriver/devtools/v87/tracing.rb +78 -0
  218. data/lib/selenium/webdriver/devtools/v87/web_audio.rb +72 -0
  219. data/lib/selenium/webdriver/devtools/v87/web_authn.rb +102 -0
  220. data/lib/selenium/webdriver/edge.rb +29 -9
  221. data/lib/selenium/webdriver/edge_chrome/bridge.rb +37 -0
  222. data/lib/selenium/webdriver/edge_chrome/driver.rb +48 -0
  223. data/lib/selenium/webdriver/edge_chrome/options.rb +37 -0
  224. data/lib/selenium/webdriver/edge_chrome/profile.rb +33 -0
  225. data/lib/selenium/webdriver/edge_chrome/service.rb +36 -0
  226. data/lib/selenium/webdriver/{edge → edge_html}/driver.rb +3 -35
  227. data/lib/selenium/webdriver/{edge → edge_html}/options.rb +26 -22
  228. data/lib/selenium/webdriver/{edge → edge_html}/service.rb +2 -6
  229. data/lib/selenium/webdriver/firefox.rb +18 -15
  230. data/lib/selenium/webdriver/firefox/bridge.rb +1 -1
  231. data/lib/selenium/webdriver/firefox/driver.rb +2 -31
  232. data/lib/selenium/webdriver/firefox/extension.rb +8 -0
  233. data/lib/selenium/webdriver/firefox/options.rb +47 -52
  234. data/lib/selenium/webdriver/firefox/profile.rb +7 -78
  235. data/lib/selenium/webdriver/firefox/service.rb +0 -4
  236. data/lib/selenium/webdriver/ie.rb +8 -7
  237. data/lib/selenium/webdriver/ie/driver.rb +0 -33
  238. data/lib/selenium/webdriver/ie/options.rb +10 -33
  239. data/lib/selenium/webdriver/ie/service.rb +5 -9
  240. data/lib/selenium/webdriver/remote.rb +16 -10
  241. data/lib/selenium/webdriver/remote/bridge.rb +38 -42
  242. data/lib/selenium/webdriver/remote/capabilities.rb +25 -7
  243. data/lib/selenium/webdriver/remote/driver.rb +6 -13
  244. data/lib/selenium/webdriver/remote/http/default.rb +10 -6
  245. data/lib/selenium/webdriver/remote/http/persistent.rb +5 -6
  246. data/lib/selenium/webdriver/safari.rb +16 -8
  247. data/lib/selenium/webdriver/safari/bridge.rb +4 -4
  248. data/lib/selenium/webdriver/safari/driver.rb +3 -30
  249. data/lib/selenium/webdriver/safari/options.rb +18 -19
  250. data/lib/selenium/webdriver/safari/service.rb +0 -4
  251. data/lib/selenium/webdriver/support.rb +1 -0
  252. data/lib/selenium/webdriver/support/color.rb +2 -2
  253. data/lib/selenium/webdriver/support/event_firing_bridge.rb +1 -1
  254. data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
  255. data/lib/selenium/webdriver/version.rb +1 -1
  256. data/selenium-webdriver.gemspec +7 -6
  257. metadata +225 -21
  258. data/lib/selenium/webdriver/firefox/binary.rb +0 -110
  259. data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
@@ -23,18 +23,10 @@ module Selenium
23
23
  class Profile
24
24
  include ProfileHelper
25
25
 
26
- VALID_PREFERENCE_TYPES = [TrueClass, FalseClass, Integer, Float, String].freeze
27
- WEBDRIVER_EXTENSION_PATH = File.expand_path("#{WebDriver.root}/selenium/webdriver/firefox/extension/webdriver.xpi")
28
- WEBDRIVER_PREFS = {
29
- native_events: 'webdriver_enable_native_events',
30
- untrusted_certs: 'webdriver_accept_untrusted_certs',
31
- untrusted_issuer: 'webdriver_assume_untrusted_issuer',
32
- port: 'webdriver_firefox_port',
33
- log_file: 'webdriver.log.file'
34
- }.freeze
26
+ VALID_PREFERENCE_TYPES = [TrueClass, FalseClass, Integer, Float, String].freeze
35
27
 
36
28
  attr_reader :name, :log_file
37
- attr_writer :secure_ssl, :native_events, :load_no_focus_lib
29
+ attr_writer :secure_ssl, :load_no_focus_lib
38
30
 
39
31
  class << self
40
32
  def ini
@@ -48,10 +40,8 @@ module Selenium
48
40
  raise Error::WebDriverError, "unable to find profile named: #{name.inspect}"
49
41
  end
50
42
 
51
- def default_preferences
52
- @default_preferences ||= JSON.parse(
53
- File.read(File.expand_path("#{WebDriver.root}/selenium/webdriver/firefox/extension/prefs.json"))
54
- ).freeze
43
+ def decoded(json)
44
+ JSON.parse(json)
55
45
  end
56
46
  end
57
47
 
@@ -70,14 +60,7 @@ module Selenium
70
60
  def initialize(model = nil)
71
61
  @model = verify_model(model)
72
62
 
73
- model_prefs = read_model_prefs
74
-
75
- if model_prefs.empty?
76
- assign_default_preferences
77
- else
78
- assign_updated_preferences(model_prefs)
79
- end
80
-
63
+ @additional_prefs = read_model_prefs
81
64
  @extensions = {}
82
65
  end
83
66
 
@@ -121,12 +104,6 @@ module Selenium
121
104
  self[WEBDRIVER_PREFS[:log_file]] = file
122
105
  end
123
106
 
124
- def add_webdriver_extension
125
- return if @extensions.key?(:webdriver)
126
-
127
- add_extension(WEBDRIVER_EXTENSION_PATH, :webdriver)
128
- end
129
-
130
107
  #
131
108
  # Add the extension (directory, .zip or .xpi) at the given path to the profile.
132
109
  #
@@ -135,26 +112,6 @@ module Selenium
135
112
  @extensions[name] = Extension.new(path)
136
113
  end
137
114
 
138
- def native_events?
139
- @native_events == true
140
- end
141
-
142
- def load_no_focus_lib?
143
- @load_no_focus_lib == true
144
- end
145
-
146
- def secure_ssl?
147
- @secure_ssl == true
148
- end
149
-
150
- def assume_untrusted_certificate_issuer?
151
- @untrusted_issuer == true
152
- end
153
-
154
- def assume_untrusted_certificate_issuer=(bool)
155
- @untrusted_issuer = bool
156
- end
157
-
158
115
  def proxy=(proxy)
159
116
  raise TypeError, "expected #{Proxy.name}, got #{proxy.inspect}:#{proxy.class}" unless proxy.is_a? Proxy
160
117
 
@@ -178,30 +135,10 @@ module Selenium
178
135
  end
179
136
  end
180
137
 
181
- def encoded
182
- Zipper.zip(layout_on_disk)
183
- end
138
+ alias_method :as_json, :encoded
184
139
 
185
140
  private
186
141
 
187
- def assign_default_preferences
188
- @native_events = DEFAULT_ENABLE_NATIVE_EVENTS
189
- @secure_ssl = DEFAULT_SECURE_SSL
190
- @untrusted_issuer = DEFAULT_ASSUME_UNTRUSTED_ISSUER
191
- @load_no_focus_lib = DEFAULT_LOAD_NO_FOCUS_LIB
192
-
193
- @additional_prefs = {}
194
- end
195
-
196
- def assign_updated_preferences(model_prefs)
197
- @native_events = model_prefs.delete(WEBDRIVER_PREFS[:native_events]) == 'true'
198
- @secure_ssl = model_prefs.delete(WEBDRIVER_PREFS[:untrusted_certs]) != 'true'
199
- @untrusted_issuer = model_prefs.delete(WEBDRIVER_PREFS[:untrusted_issuer]) == 'true'
200
- # not stored in profile atm, so will always be false.
201
- @load_no_focus_lib = model_prefs.delete(WEBDRIVER_PREFS[:load_no_focus_lib]) == 'true'
202
- @additional_prefs = model_prefs
203
- end
204
-
205
142
  def set_manual_proxy_preference(key, value)
206
143
  return unless value
207
144
 
@@ -242,15 +179,7 @@ module Selenium
242
179
 
243
180
  def update_user_prefs_in(directory)
244
181
  path = File.join(directory, 'user.js')
245
- prefs = read_user_prefs(path)
246
-
247
- prefs.merge! self.class.default_preferences.fetch 'mutable'
248
- prefs.merge! @additional_prefs
249
- prefs.merge! self.class.default_preferences.fetch 'frozen'
250
-
251
- prefs[WEBDRIVER_PREFS[:untrusted_certs]] = !secure_ssl?
252
- prefs[WEBDRIVER_PREFS[:native_events]] = native_events?
253
- prefs[WEBDRIVER_PREFS[:untrusted_issuer]] = assume_untrusted_certificate_issuer?
182
+ prefs = read_user_prefs(path).merge(@additional_prefs)
254
183
 
255
184
  # If the user sets the home page, we should also start up there
256
185
  prefs['startup.homepage_welcome_url'] = prefs['browser.startup.homepage']
@@ -20,10 +20,6 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Firefox
23
- #
24
- # @api private
25
- #
26
-
27
23
  class Service < WebDriver::Service
28
24
  DEFAULT_PORT = 4444
29
25
  EXECUTABLE = 'geckodriver'
@@ -17,25 +17,26 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
- require 'selenium/webdriver/ie/driver'
21
- require 'selenium/webdriver/ie/options'
22
-
23
20
  module Selenium
24
21
  module WebDriver
25
22
  module IE
23
+ autoload :Driver, 'selenium/webdriver/ie/driver'
24
+ autoload :Options, 'selenium/webdriver/ie/options'
25
+ autoload :Service, 'selenium/webdriver/ie/service'
26
+
26
27
  def self.driver_path=(path)
27
28
  WebDriver.logger.deprecate 'Selenium::WebDriver::IE#driver_path=',
28
- 'Selenium::WebDriver::IE::Service#driver_path='
29
+ 'Selenium::WebDriver::IE::Service#driver_path=',
30
+ id: :driver_path
29
31
  Selenium::WebDriver::IE::Service.driver_path = path
30
32
  end
31
33
 
32
34
  def self.driver_path
33
35
  WebDriver.logger.deprecate 'Selenium::WebDriver::IE#driver_path',
34
- 'Selenium::WebDriver::IE::Service#driver_path'
36
+ 'Selenium::WebDriver::IE::Service#driver_path',
37
+ id: :driver_path
35
38
  Selenium::WebDriver::IE::Service.driver_path
36
39
  end
37
40
  end # IE
38
41
  end # WebDriver
39
42
  end # Selenium
40
-
41
- require 'selenium/webdriver/ie/service'
@@ -29,43 +29,10 @@ module Selenium
29
29
 
30
30
  class Driver < WebDriver::Driver
31
31
  include DriverExtensions::HasWebStorage
32
- include DriverExtensions::TakesScreenshot
33
-
34
- def initialize(opts = {})
35
- opts[:desired_capabilities] = create_capabilities(opts)
36
-
37
- opts[:url] ||= service_url(opts)
38
-
39
- listener = opts.delete(:listener)
40
- desired_capabilities = opts.delete(:desired_capabilities)
41
-
42
- @bridge = Remote::Bridge.new(opts)
43
- @bridge.create_session(desired_capabilities)
44
-
45
- super(@bridge, listener: listener)
46
- end
47
32
 
48
33
  def browser
49
34
  :internet_explorer
50
35
  end
51
-
52
- def quit
53
- super
54
- ensure
55
- @service&.stop
56
- end
57
-
58
- private
59
-
60
- def create_capabilities(opts)
61
- caps = opts.delete(:desired_capabilities) { Remote::Capabilities.internet_explorer }
62
- options = opts.delete(:options) { Options.new }
63
- options = options.as_json
64
- caps.merge!(options) unless options.empty?
65
-
66
- caps
67
- end
68
-
69
36
  end # Driver
70
37
  end # IE
71
38
  end # WebDriver
@@ -20,7 +20,7 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module IE
23
- class Options
23
+ class Options < WebDriver::Options
24
24
  KEY = 'se:ieOptions'
25
25
  SCROLL_TOP = 0
26
26
  SCROLL_BOTTOM = 1
@@ -41,6 +41,7 @@ module Selenium
41
41
  use_per_process_proxy: 'ie.usePerProcessProxy',
42
42
  validate_cookie_document_type: 'ie.validateCookieDocumentType'
43
43
  }.freeze
44
+ BROWSER = 'internet explorer'
44
45
 
45
46
  CAPABILITIES.each_key do |key|
46
47
  define_method key do
@@ -52,7 +53,7 @@ module Selenium
52
53
  end
53
54
  end
54
55
 
55
- attr_reader :args, :options
56
+ attr_reader :args
56
57
 
57
58
  #
58
59
  # Create a new Options instance
@@ -86,8 +87,9 @@ module Selenium
86
87
  #
87
88
 
88
89
  def initialize(**opts)
89
- @args = Set.new(opts.delete(:args) || [])
90
- @options = opts
90
+ @args = (opts.delete(:args) || []).to_set
91
+ super(**opts)
92
+
91
93
  @options[:native_events] = true if @options[:native_events].nil?
92
94
  end
93
95
 
@@ -101,36 +103,11 @@ module Selenium
101
103
  @args << arg
102
104
  end
103
105
 
104
- #
105
- # Add a new option not yet handled by these bindings.
106
- #
107
- # @example
108
- # options = Selenium::WebDriver::IE::Options.new
109
- # options.add_option(:foo, 'bar')
110
- #
111
- # @param [String, Symbol] name Name of the option
112
- # @param [Boolean, String, Integer] value Value of the option
113
- #
114
-
115
- def add_option(name, value)
116
- @options[name] = value
117
- end
118
-
119
- #
120
- # @api private
121
- #
122
-
123
- def as_json(*)
124
- opts = {}
125
-
126
- CAPABILITIES.each do |capability_alias, capability_name|
127
- capability_value = @options.delete(capability_alias)
128
- opts[capability_name] = capability_value unless capability_value.nil?
129
- end
130
- opts['ie.browserCommandLineSwitches'] = @args.to_a.join(' ') if @args.any?
131
- opts.merge!(@options)
106
+ private
132
107
 
133
- {KEY => opts}
108
+ def process_browser_options(browser_options)
109
+ options = browser_options[KEY]
110
+ options['ie.browserCommandLineSwitches'] = @args.to_a.join(' ') if @args.any?
134
111
  end
135
112
  end # Options
136
113
  end # IE
@@ -20,10 +20,6 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module IE
23
- #
24
- # @api private
25
- #
26
-
27
23
  class Service < WebDriver::Service
28
24
  DEFAULT_PORT = 5555
29
25
  EXECUTABLE = 'IEDriverServer'
@@ -40,11 +36,11 @@ module Selenium
40
36
  def extract_service_args(driver_opts)
41
37
  driver_args = super
42
38
  driver_opts = driver_opts.dup
43
- driver_args << "--log-level=#{driver_opts.delete(:log_level).to_s.upcase}" if driver_opts.key?(:log_level)
44
- driver_args << "--log-file=#{driver_opts.delete(:log_file)}" if driver_opts.key?(:log_file)
45
- driver_args << "--implementation=#{driver_opts.delete(:implementation).to_s.upcase}" if driver_opts.key?(:implementation)
46
- driver_args << "--host=#{driver_opts.delete(:host)}" if driver_opts.key?(:host)
47
- driver_args << "--extract_path=#{driver_opts.delete(:extract_path)}" if driver_opts.key?(:extract_path)
39
+ driver_args << "--log-level=#{driver_opts[:log_level].to_s.upcase}" if driver_opts.key?(:log_level)
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)
42
+ driver_args << "--host=#{driver_opts[:host]}" if driver_opts.key?(:host)
43
+ driver_args << "--extract_path=#{driver_opts[:extract_path]}" if driver_opts.key?(:extract_path)
48
44
  driver_args << "--silent" if driver_opts[:silent] == true
49
45
  driver_args
50
46
  end
@@ -19,13 +19,19 @@
19
19
 
20
20
  require 'uri'
21
21
 
22
- require 'selenium/webdriver/remote/bridge'
23
- require 'selenium/webdriver/remote/driver'
24
- require 'selenium/webdriver/remote/response'
25
- require 'selenium/webdriver/remote/server_error'
26
- require 'selenium/webdriver/remote/http/common'
27
- require 'selenium/webdriver/remote/http/default'
28
-
29
- require 'selenium/webdriver/remote/bridge'
30
- require 'selenium/webdriver/remote/capabilities'
31
- require 'selenium/webdriver/remote/commands'
22
+ module Selenium
23
+ module WebDriver
24
+ module Remote
25
+ autoload :Bridge, 'selenium/webdriver/remote/bridge'
26
+ autoload :Driver, 'selenium/webdriver/remote/driver'
27
+ autoload :Response, 'selenium/webdriver/remote/response'
28
+ autoload :ServerError, 'selenium/webdriver/remote/server_error'
29
+ autoload :Capabilities, 'selenium/webdriver/remote/capabilities'
30
+ autoload :COMMANDS, 'selenium/webdriver/remote/commands'
31
+ module Http
32
+ autoload :Common, 'selenium/webdriver/remote/http/common'
33
+ autoload :Default, 'selenium/webdriver/remote/http/default'
34
+ end
35
+ end
36
+ end
37
+ end
@@ -30,30 +30,17 @@ module Selenium
30
30
 
31
31
  #
32
32
  # Initializes the bridge with the given server URL
33
- # @param [Hash] opts options for the driver
34
- # @option opts [String] :url url for the remote server
35
- # @option opts [Object] :http_client an HTTP client instance that implements the same protocol as Http::Default
36
- # @option opts [Capabilities] :desired_capabilities an instance of Remote::Capabilities describing the capabilities you want
33
+ # @param [String, URI] :url url for the remote server
34
+ # @param [Object] :http_client an HTTP client instance that implements the same protocol as Http::Default
37
35
  # @api private
38
36
  #
39
37
 
40
- def initialize(opts = {})
41
- opts = opts.dup
42
-
43
- http_client = opts.delete(:http_client) { Http::Default.new }
44
- url = opts.delete(:url) { "http://#{Platform.localhost}:#{PORT}/wd/hub" }
45
- opts.delete(:options)
46
-
47
- unless opts.empty?
48
- raise ArgumentError, "unknown option#{'s' if opts.size != 1}: #{opts.inspect}"
49
- end
50
-
38
+ def initialize(http_client: nil, url:)
51
39
  uri = url.is_a?(URI) ? url : URI.parse(url)
52
- uri.path += '/' unless %r{\/$}.match?(uri.path)
53
-
54
- http_client.server_url = uri
40
+ uri.path += '/' unless uri.path.end_with?('/')
55
41
 
56
- @http = http_client
42
+ @http = http_client || Http::Default.new
43
+ @http.server_url = uri
57
44
  @file_detector = nil
58
45
  end
59
46
 
@@ -61,8 +48,8 @@ module Selenium
61
48
  # Creates session.
62
49
  #
63
50
 
64
- def create_session(desired_capabilities, options = nil)
65
- response = execute(:new_session, {}, merged_capabilities(desired_capabilities, options))
51
+ def create_session(capabilities)
52
+ response = execute(:new_session, {}, {capabilities: {firstMatch: [capabilities]}})
66
53
 
67
54
  @session_id = response['sessionId']
68
55
  capabilities = response['capabilities']
@@ -264,6 +251,10 @@ module Selenium
264
251
  execute :take_screenshot
265
252
  end
266
253
 
254
+ def element_screenshot(element)
255
+ execute :take_element_screenshot, id: element.ref
256
+ end
257
+
267
258
  #
268
259
  # HTML 5
269
260
  #
@@ -525,23 +516,28 @@ module Selenium
525
516
  alias_method :switch_to_active_element, :active_element
526
517
 
527
518
  def find_element_by(how, what, parent = nil)
528
- how, what = convert_locators(how, what)
519
+ how, what = convert_locator(how, what)
520
+
521
+ return execute_atom(:findElements, Support::RelativeLocator.new(what).as_json).first if how == 'relative'
529
522
 
530
523
  id = if parent
531
- execute :find_child_element, {id: parent}, {using: how, value: what}
524
+ execute :find_child_element, {id: parent}, {using: how, value: what.to_s}
532
525
  else
533
- execute :find_element, {}, {using: how, value: what}
526
+ execute :find_element, {}, {using: how, value: what.to_s}
534
527
  end
528
+
535
529
  Element.new self, element_id_from(id)
536
530
  end
537
531
 
538
532
  def find_elements_by(how, what, parent = nil)
539
- how, what = convert_locators(how, what)
533
+ how, what = convert_locator(how, what)
534
+
535
+ return execute_atom :findElements, Support::RelativeLocator.new(what).as_json if how == 'relative'
540
536
 
541
537
  ids = if parent
542
- execute :find_child_elements, {id: parent}, {using: how, value: what}
538
+ execute :find_child_elements, {id: parent}, {using: how, value: what.to_s}
543
539
  else
544
- execute :find_elements, {}, {using: how, value: what}
540
+ execute :find_elements, {}, {using: how, value: what.to_s}
545
541
  end
546
542
 
547
543
  ids.map { |id| Element.new self, element_id_from(id) }
@@ -579,16 +575,6 @@ module Selenium
579
575
  COMMANDS[command]
580
576
  end
581
577
 
582
- def merged_capabilities(capabilities, options = nil)
583
- capabilities.merge!(options.as_json) if options
584
-
585
- {
586
- capabilities: {
587
- firstMatch: [capabilities]
588
- }
589
- }
590
- end
591
-
592
578
  def unwrap_script_result(arg)
593
579
  case arg
594
580
  when Array
@@ -607,20 +593,30 @@ module Selenium
607
593
  id['ELEMENT'] || id['element-6066-11e4-a52e-4f735466cecf']
608
594
  end
609
595
 
610
- def convert_locators(how, what)
596
+ def convert_locator(how, what)
597
+ how = SearchContext::FINDERS[how.to_sym] || how
598
+
611
599
  case how
612
600
  when 'class name'
613
601
  how = 'css selector'
614
- what = ".#{escape_css(what)}"
602
+ what = ".#{escape_css(what.to_s)}"
615
603
  when 'id'
616
604
  how = 'css selector'
617
- what = "##{escape_css(what)}"
605
+ what = "##{escape_css(what.to_s)}"
618
606
  when 'name'
619
607
  how = 'css selector'
620
- what = "*[name='#{escape_css(what)}']"
608
+ what = "*[name='#{escape_css(what.to_s)}']"
621
609
  when 'tag name'
622
610
  how = 'css selector'
623
611
  end
612
+
613
+ if what.is_a?(Hash)
614
+ what = what.each_with_object({}) do |(h, w), hash|
615
+ h, w = convert_locator(h.to_s, w)
616
+ hash[h] = w
617
+ end
618
+ end
619
+
624
620
  [how, what]
625
621
  end
626
622
 
@@ -631,7 +627,7 @@ module Selenium
631
627
  # @see https://mathiasbynens.be/notes/css-escapes
632
628
  def escape_css(string)
633
629
  string = string.gsub(ESCAPE_CSS_REGEXP) { |match| "\\#{match}" }
634
- string = "\\#{UNICODE_CODE_POINT + Integer(string[0])} #{string[1..-1]}" if !string.empty? && string[0].match?(/[[:digit:]]/)
630
+ string = "\\#{UNICODE_CODE_POINT + Integer(string[0])} #{string[1..-1]}" if string[0]&.match?(/[[:digit:]]/)
635
631
 
636
632
  string
637
633
  end