selenium-webdriver 2.53.3 → 3.142.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +665 -8
  3. data/Gemfile +2 -0
  4. data/LICENSE +1 -1
  5. data/README.md +2 -3
  6. data/lib/selenium/server.rb +76 -73
  7. data/lib/selenium/webdriver/atoms/getAttribute.js +7 -0
  8. data/lib/selenium/webdriver/atoms/isDisplayed.js +102 -0
  9. data/lib/selenium/webdriver/{phantomjs.rb → atoms.rb} +10 -14
  10. data/lib/selenium/webdriver/chrome/bridge.rb +30 -101
  11. data/lib/selenium/webdriver/chrome/driver.rb +127 -0
  12. data/lib/selenium/webdriver/chrome/options.rb +190 -0
  13. data/lib/selenium/webdriver/chrome/profile.rb +21 -20
  14. data/lib/selenium/webdriver/chrome/service.rb +26 -93
  15. data/lib/selenium/webdriver/chrome.rb +15 -6
  16. data/lib/selenium/webdriver/common/action_builder.rb +52 -58
  17. data/lib/selenium/webdriver/common/alert.rb +7 -15
  18. data/lib/selenium/webdriver/common/bridge_helper.rb +18 -22
  19. data/lib/selenium/webdriver/common/driver.rb +72 -72
  20. data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +45 -0
  21. data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +50 -0
  22. data/lib/selenium/webdriver/common/driver_extensions/{has_input_devices.rb → has_debugger.rb} +11 -27
  23. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +6 -10
  24. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +51 -0
  25. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +7 -8
  26. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +51 -0
  27. data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +2 -4
  28. data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +2 -4
  29. data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +3 -5
  30. data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +2 -5
  31. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +6 -9
  32. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +9 -7
  33. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +3 -8
  34. data/lib/selenium/webdriver/common/element.rb +59 -39
  35. data/lib/selenium/webdriver/common/error.rb +259 -104
  36. data/lib/selenium/webdriver/common/file_reaper.rb +6 -14
  37. data/lib/selenium/webdriver/common/html5/local_storage.rb +8 -10
  38. data/lib/selenium/webdriver/common/html5/session_storage.rb +8 -10
  39. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +8 -16
  40. data/lib/selenium/webdriver/common/interactions/input_device.rb +54 -0
  41. data/lib/selenium/webdriver/common/interactions/interaction.rb +53 -0
  42. data/lib/selenium/webdriver/{safari/browser.rb → common/interactions/interactions.rb} +17 -14
  43. data/lib/selenium/webdriver/common/interactions/key_actions.rb +145 -0
  44. data/lib/selenium/webdriver/common/interactions/key_input.rb +66 -0
  45. data/lib/selenium/webdriver/{android.rb → common/interactions/none_input.rb} +14 -6
  46. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +363 -0
  47. data/lib/selenium/webdriver/common/interactions/pointer_input.rb +139 -0
  48. data/lib/selenium/webdriver/common/keyboard.rb +10 -14
  49. data/lib/selenium/webdriver/common/keys.rb +102 -82
  50. data/lib/selenium/webdriver/common/log_entry.rb +7 -8
  51. data/lib/selenium/webdriver/common/logger.rb +115 -0
  52. data/lib/selenium/webdriver/common/logs.rb +4 -6
  53. data/lib/selenium/webdriver/common/manager.rb +177 -0
  54. data/lib/selenium/webdriver/common/mouse.rb +12 -14
  55. data/lib/selenium/webdriver/common/navigation.rb +4 -6
  56. data/lib/selenium/webdriver/common/options.rb +26 -127
  57. data/lib/selenium/webdriver/common/platform.rb +75 -101
  58. data/lib/selenium/webdriver/common/port_prober.rb +7 -19
  59. data/lib/selenium/webdriver/common/profile_helper.rb +8 -11
  60. data/lib/selenium/webdriver/common/proxy.rb +68 -74
  61. data/lib/selenium/webdriver/common/search_context.rb +28 -37
  62. data/lib/selenium/webdriver/common/service.rb +219 -0
  63. data/lib/selenium/webdriver/common/socket_lock.rb +15 -16
  64. data/lib/selenium/webdriver/common/socket_poller.rb +30 -28
  65. data/lib/selenium/webdriver/common/target_locator.rb +16 -18
  66. data/lib/selenium/webdriver/common/timeouts.rb +6 -8
  67. data/lib/selenium/webdriver/common/touch_action_builder.rb +5 -10
  68. data/lib/selenium/webdriver/common/touch_screen.rb +22 -23
  69. data/lib/selenium/webdriver/common/w3c_action_builder.rb +212 -0
  70. data/lib/selenium/webdriver/common/w3c_manager.rb +45 -0
  71. data/lib/selenium/webdriver/common/wait.rb +17 -16
  72. data/lib/selenium/webdriver/common/window.rb +50 -17
  73. data/lib/selenium/webdriver/common/zipper.rb +9 -13
  74. data/lib/selenium/webdriver/common.rb +21 -7
  75. data/lib/selenium/webdriver/edge/bridge.rb +34 -63
  76. data/lib/selenium/webdriver/edge/driver.rb +66 -0
  77. data/lib/selenium/webdriver/edge/options.rb +80 -0
  78. data/lib/selenium/webdriver/edge/service.rb +23 -95
  79. data/lib/selenium/webdriver/edge.rb +13 -13
  80. data/lib/selenium/webdriver/firefox/binary.rb +45 -60
  81. data/lib/selenium/webdriver/firefox/driver.rb +50 -0
  82. data/lib/selenium/webdriver/firefox/extension/prefs.json +3 -12
  83. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  84. data/lib/selenium/webdriver/firefox/extension.rb +20 -10
  85. data/lib/selenium/webdriver/firefox/launcher.rb +16 -22
  86. data/lib/selenium/webdriver/firefox/legacy/driver.rb +83 -0
  87. data/lib/selenium/webdriver/firefox/marionette/bridge.rb +49 -0
  88. data/lib/selenium/webdriver/firefox/marionette/driver.rb +90 -0
  89. data/lib/selenium/webdriver/firefox/options.rb +162 -0
  90. data/lib/selenium/webdriver/firefox/profile.rb +47 -48
  91. data/lib/selenium/webdriver/firefox/profiles_ini.rb +11 -18
  92. data/lib/selenium/webdriver/firefox/service.rb +24 -95
  93. data/lib/selenium/webdriver/firefox/util.rb +2 -4
  94. data/lib/selenium/webdriver/firefox.rb +27 -12
  95. data/lib/selenium/webdriver/ie/driver.rb +85 -0
  96. data/lib/selenium/webdriver/ie/options.rb +138 -0
  97. data/lib/selenium/webdriver/ie/service.rb +54 -0
  98. data/lib/selenium/webdriver/ie.rb +12 -10
  99. data/lib/selenium/webdriver/remote/bridge.rb +100 -564
  100. data/lib/selenium/webdriver/remote/capabilities.rb +98 -100
  101. data/lib/selenium/webdriver/remote/driver.rb +51 -0
  102. data/lib/selenium/webdriver/remote/http/common.rb +34 -22
  103. data/lib/selenium/webdriver/remote/http/curb.rb +13 -14
  104. data/lib/selenium/webdriver/remote/http/default.rb +62 -43
  105. data/lib/selenium/webdriver/remote/http/persistent.rb +12 -9
  106. data/lib/selenium/webdriver/remote/oss/bridge.rb +594 -0
  107. data/lib/selenium/webdriver/remote/oss/commands.rb +223 -0
  108. data/lib/selenium/webdriver/remote/response.rb +48 -28
  109. data/lib/selenium/webdriver/remote/server_error.rb +3 -5
  110. data/lib/selenium/webdriver/remote/w3c/bridge.rb +605 -0
  111. data/lib/selenium/webdriver/remote/w3c/capabilities.rb +310 -0
  112. data/lib/selenium/webdriver/remote/w3c/commands.rb +157 -0
  113. data/lib/selenium/webdriver/remote.rb +10 -16
  114. data/lib/selenium/webdriver/safari/bridge.rb +17 -101
  115. data/lib/selenium/webdriver/{firefox/w3c_bridge.rb → safari/driver.rb} +27 -25
  116. data/lib/selenium/webdriver/safari/options.rb +29 -31
  117. data/lib/selenium/webdriver/safari/service.rb +38 -0
  118. data/lib/selenium/webdriver/safari.rb +27 -27
  119. data/lib/selenium/webdriver/support/abstract_event_listener.rb +19 -4
  120. data/lib/selenium/webdriver/support/block_event_listener.rb +3 -5
  121. data/lib/selenium/webdriver/support/color.rb +60 -43
  122. data/lib/selenium/webdriver/support/escaper.rb +43 -0
  123. data/lib/selenium/webdriver/support/event_firing_bridge.rb +39 -41
  124. data/lib/selenium/webdriver/support/select.rb +45 -97
  125. data/lib/selenium/webdriver/support.rb +3 -2
  126. data/lib/selenium/webdriver/{iphone.rb → version.rb} +3 -7
  127. data/lib/selenium/webdriver.rb +36 -23
  128. data/lib/selenium-webdriver.rb +2 -2
  129. data/selenium-webdriver.gemspec +42 -29
  130. metadata +331 -262
  131. data/lib/selenium/client/base.rb +0 -151
  132. data/lib/selenium/client/driver.rb +0 -29
  133. data/lib/selenium/client/errors.rb +0 -28
  134. data/lib/selenium/client/extensions.rb +0 -132
  135. data/lib/selenium/client/idiomatic.rb +0 -507
  136. data/lib/selenium/client/javascript_expression_builder.rb +0 -135
  137. data/lib/selenium/client/javascript_frameworks/jquery.rb +0 -32
  138. data/lib/selenium/client/javascript_frameworks/prototype.rb +0 -32
  139. data/lib/selenium/client/legacy_driver.rb +0 -1722
  140. data/lib/selenium/client/protocol.rb +0 -123
  141. data/lib/selenium/client/selenium_helper.rb +0 -49
  142. data/lib/selenium/client.rb +0 -57
  143. data/lib/selenium/rake/server_task.rb +0 -176
  144. data/lib/selenium/webdriver/android/bridge.rb +0 -68
  145. data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -28
  146. data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -61
  147. data/lib/selenium/webdriver/common/html5/location.rb +0 -19
  148. data/lib/selenium/webdriver/common/w3c_error.rb +0 -194
  149. data/lib/selenium/webdriver/edge/legacy_support.rb +0 -117
  150. data/lib/selenium/webdriver/firefox/bridge.rb +0 -89
  151. data/lib/selenium/webdriver/ie/bridge.rb +0 -88
  152. data/lib/selenium/webdriver/ie/server.rb +0 -133
  153. data/lib/selenium/webdriver/iphone/bridge.rb +0 -64
  154. data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -78
  155. data/lib/selenium/webdriver/phantomjs/service.rb +0 -130
  156. data/lib/selenium/webdriver/remote/commands.rb +0 -211
  157. data/lib/selenium/webdriver/remote/w3c_bridge.rb +0 -668
  158. data/lib/selenium/webdriver/remote/w3c_capabilities.rb +0 -236
  159. data/lib/selenium/webdriver/remote/w3c_commands.rb +0 -132
  160. data/lib/selenium/webdriver/safari/resources/client.js +0 -7255
  161. data/lib/selenium/webdriver/safari/server.rb +0 -187
  162. data/lib/selenium-client.rb +0 -21
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -19,7 +19,6 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
-
23
22
  #
24
23
  # The main class through which you control the browser.
25
24
  #
@@ -33,7 +32,6 @@ module Selenium
33
32
  include SearchContext
34
33
 
35
34
  class << self
36
-
37
35
  #
38
36
  # @api private
39
37
  #
@@ -43,42 +41,24 @@ module Selenium
43
41
  #
44
42
 
45
43
  def for(browser, opts = {})
46
- listener = opts.delete(:listener)
47
-
48
- bridge = case browser
49
- when :firefox, :ff, :marionette
50
- if Remote::W3CCapabilities.w3c?(opts)
51
- Firefox::W3CBridge.new(opts)
52
- else
53
- Firefox::Bridge.new(opts)
54
- end
55
- when :remote
56
- if Remote::W3CCapabilities.w3c?(opts)
57
- Remote::W3CBridge.new(opts)
58
- else
59
- Remote::Bridge.new(opts)
60
- end
61
- when :ie, :internet_explorer
62
- IE::Bridge.new(opts)
63
- when :chrome
64
- Chrome::Bridge.new(opts)
65
- when :edge
66
- Edge::Bridge.new(opts)
67
- when :android
68
- Android::Bridge.new(opts)
69
- when :iphone
70
- IPhone::Bridge.new(opts)
71
- when :phantomjs
72
- PhantomJS::Bridge.new(opts)
73
- when :safari
74
- Safari::Bridge.new(opts)
75
- else
76
- raise ArgumentError, "unknown driver: #{browser.inspect}"
77
- end
78
-
79
- bridge = Support::EventFiringBridge.new(bridge, listener) if listener
80
-
81
- new(bridge)
44
+ case browser
45
+ when :chrome
46
+ Chrome::Driver.new(opts)
47
+ when :internet_explorer, :ie
48
+ IE::Driver.new(opts)
49
+ when :safari
50
+ Safari::Driver.new(opts)
51
+ when :phantomjs
52
+ PhantomJS::Driver.new(opts)
53
+ when :firefox, :ff
54
+ Firefox::Driver.new(opts)
55
+ when :edge
56
+ Edge::Driver.new(opts)
57
+ when :remote
58
+ Remote::Driver.new(opts)
59
+ else
60
+ raise ArgumentError, "unknown driver: #{browser.inspect}"
61
+ end
82
62
  end
83
63
  end
84
64
 
@@ -89,17 +69,13 @@ module Selenium
89
69
  # @api private
90
70
  #
91
71
 
92
- def initialize(bridge)
72
+ def initialize(bridge, listener: nil)
93
73
  @bridge = bridge
94
-
95
- # TODO: refactor this away
96
- unless bridge.driver_extensions.empty?
97
- extend(*bridge.driver_extensions)
98
- end
74
+ @bridge = Support::EventFiringBridge.new(bridge, listener) if listener
99
75
  end
100
76
 
101
77
  def inspect
102
- '#<%s:0x%x browser=%s>' % [self.class, hash*2, bridge.browser.inspect]
78
+ format '#<%<class>s:0x%<hash>x browser=%<browser>s>', class: self.class, hash: hash * 2, browser: bridge.browser.inspect
103
79
  end
104
80
 
105
81
  #
@@ -121,12 +97,29 @@ module Selenium
121
97
  end
122
98
 
123
99
  #
124
- # @return [Options]
125
- # @see Options
100
+ # @return [Manager]
101
+ # @see Manager
126
102
  #
127
103
 
128
104
  def manage
129
- @manage ||= WebDriver::Options.new(bridge)
105
+ bridge.manage
106
+ end
107
+
108
+ #
109
+ # @return [ActionBuilder, W3CActionBuilder]
110
+ # @see ActionBuilder, W3CActionBuilder
111
+ #
112
+
113
+ def action
114
+ bridge.action
115
+ end
116
+
117
+ def mouse
118
+ bridge.mouse
119
+ end
120
+
121
+ def keyboard
122
+ bridge.keyboard
130
123
  end
131
124
 
132
125
  #
@@ -144,7 +137,7 @@ module Selenium
144
137
  #
145
138
 
146
139
  def current_url
147
- bridge.getCurrentUrl
140
+ bridge.url
148
141
  end
149
142
 
150
143
  #
@@ -154,7 +147,7 @@ module Selenium
154
147
  #
155
148
 
156
149
  def title
157
- bridge.getTitle
150
+ bridge.title
158
151
  end
159
152
 
160
153
  #
@@ -164,7 +157,7 @@ module Selenium
164
157
  #
165
158
 
166
159
  def page_source
167
- bridge.getPageSource
160
+ bridge.page_source
168
161
  end
169
162
 
170
163
  #
@@ -191,7 +184,7 @@ module Selenium
191
184
  #
192
185
 
193
186
  def window_handles
194
- bridge.getWindowHandles
187
+ bridge.window_handles
195
188
  end
196
189
 
197
190
  #
@@ -201,7 +194,7 @@ module Selenium
201
194
  #
202
195
 
203
196
  def window_handle
204
- bridge.getCurrentWindowHandle
197
+ bridge.window_handle
205
198
  end
206
199
 
207
200
  #
@@ -209,7 +202,7 @@ module Selenium
209
202
  #
210
203
  # @param [String] script
211
204
  # JavaScript source to execute
212
- # @param [WebDriver::Element,Integer, Float, Boolean, NilClass, String, Array] *args
205
+ # @param [WebDriver::Element, Integer, Float, Boolean, NilClass, String, Array] args
213
206
  # Arguments will be available in the given script in the 'arguments' pseudo-array.
214
207
  #
215
208
  # @return [WebDriver::Element,Integer,Float,Boolean,NilClass,String,Array]
@@ -217,7 +210,7 @@ module Selenium
217
210
  #
218
211
 
219
212
  def execute_script(script, *args)
220
- bridge.executeScript(script, *args)
213
+ bridge.execute_script(script, *args)
221
214
  end
222
215
 
223
216
  # Execute an asynchronous piece of JavaScript in the context of the
@@ -229,27 +222,26 @@ module Selenium
229
222
  #
230
223
  # @param [String] script
231
224
  # JavaScript source to execute
232
- # @param [WebDriver::Element,Integer, Float, Boolean, NilClass, String, Array] *args
225
+ # @param [WebDriver::Element,Integer, Float, Boolean, NilClass, String, Array] args
233
226
  # Arguments to the script. May be empty.
234
227
  #
235
228
  # @return [WebDriver::Element,Integer,Float,Boolean,NilClass,String,Array]
236
229
  #
237
230
 
238
231
  def execute_async_script(script, *args)
239
- bridge.executeAsyncScript(script, *args)
232
+ bridge.execute_async_script(script, *args)
240
233
  end
241
234
 
242
-
243
235
  #-------------------------------- sugar --------------------------------
244
236
 
245
237
  #
246
- # driver.first(:id, 'foo')
238
+ # driver.first(id: 'foo')
247
239
  #
248
240
 
249
241
  alias_method :first, :find_element
250
242
 
251
243
  #
252
- # driver.all(:class, 'bar') #=> [#<WebDriver::Element:0x1011c3b88, ...]
244
+ # driver.all(class: 'bar') #=> [#<WebDriver::Element:0x1011c3b88, ...]
253
245
  #
254
246
 
255
247
  alias_method :all, :find_elements
@@ -263,7 +255,7 @@ module Selenium
263
255
  # Get the first element matching the given selector. If given a
264
256
  # String or Symbol, it will be used as the id of the element.
265
257
  #
266
- # @param [String,Hash] id or selector
258
+ # @param [String,Hash] sel id or selector
267
259
  # @return [WebDriver::Element]
268
260
  #
269
261
  # Examples:
@@ -273,9 +265,7 @@ module Selenium
273
265
  #
274
266
 
275
267
  def [](sel)
276
- if sel.kind_of?(String) || sel.kind_of?(Symbol)
277
- sel = { :id => sel }
278
- end
268
+ sel = {id: sel} if sel.is_a?(String) || sel.is_a?(Symbol)
279
269
 
280
270
  find_element sel
281
271
  end
@@ -293,16 +283,26 @@ module Selenium
293
283
  # @see SearchContext
294
284
  #
295
285
 
296
- def ref
297
- nil
298
- end
286
+ def ref; end
299
287
 
300
288
  private
301
289
 
302
- def bridge
303
- @bridge
304
- end
290
+ attr_reader :bridge
291
+
292
+ def service_url(opts)
293
+ @service = opts.delete(:service)
294
+ %i[driver_opts driver_path port].each do |key|
295
+ next unless opts.key? key
305
296
 
297
+ WebDriver.logger.deprecate(":#{key}", ':service with an instance of Selenium::WebDriver::Service')
298
+ end
299
+ @service ||= Service.send(browser,
300
+ args: opts.delete(:driver_opts),
301
+ path: opts.delete(:driver_path),
302
+ port: opts.delete(:port))
303
+ @service.start
304
+ @service.uri
305
+ end
306
306
  end # Driver
307
307
  end # WebDriver
308
308
  end # Selenium
@@ -0,0 +1,45 @@
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 DownloadsFiles
24
+
25
+ #
26
+ # Sets download path for Chromium.
27
+ #
28
+ # @param [String] path
29
+ #
30
+
31
+ def download_path=(path)
32
+ params = {
33
+ 'cmd' => 'Page.setDownloadBehavior',
34
+ 'params' => {
35
+ 'behavior' => 'allow',
36
+ 'downloadPath' => path
37
+ }
38
+ }
39
+ @bridge.send_command(params)
40
+ end
41
+
42
+ end # DownloadsFiles
43
+ end # DriverExtensions
44
+ end # WebDriver
45
+ end # Selenium
@@ -0,0 +1,50 @@
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 HasAddons
24
+
25
+ #
26
+ # Installs addon.
27
+ #
28
+ # @param [String] path Full path to addon file
29
+ # @param [Boolean] temporary
30
+ # @return [String] identifier of installed addon
31
+ #
32
+
33
+ def install_addon(path, temporary = nil)
34
+ @bridge.install_addon(path, temporary)
35
+ end
36
+
37
+ #
38
+ # Uninstalls addon.
39
+ #
40
+ # @param [String] id Identifier of installed addon
41
+ #
42
+
43
+ def uninstall_addon(id)
44
+ @bridge.uninstall_addon(id)
45
+ end
46
+
47
+ end # HasAddons
48
+ end # DriverExtensions
49
+ end # WebDriver
50
+ end # Selenium
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -19,40 +19,24 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
-
23
- #
24
- # @api private
25
- #
26
-
27
22
  module DriverExtensions
28
- module HasInputDevices
29
-
30
- #
31
- # @return [ActionBuilder]
32
- # @api public
33
- #
34
-
35
- def action
36
- ActionBuilder.new mouse, keyboard
37
- end
23
+ module HasDebugger
38
24
 
39
25
  #
40
- # @api private
26
+ # Attaches debugger to session.
41
27
  #
42
-
43
- def mouse
44
- Mouse.new @bridge
45
- end
46
-
28
+ # @example
29
+ # driver.attach_debugger
30
+ # driver.execute_script('debugger')
47
31
  #
48
- # @api private
32
+ # @return [Hash]
49
33
  #
50
34
 
51
- def keyboard
52
- Keyboard.new @bridge
35
+ def attach_debugger
36
+ @bridge.attach_debugger
53
37
  end
54
38
 
55
- end # HasInputDevices
39
+ end # HasDebugger
56
40
  end # DriverExtensions
57
41
  end # WebDriver
58
42
  end # Selenium
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -20,25 +20,21 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
-
24
23
  module HasLocation
25
24
  def location
26
- @bridge.getLocation
25
+ @bridge.location
27
26
  end
28
27
 
29
28
  def location=(loc)
30
- unless loc.kind_of?(Location)
31
- raise TypeError, "expected #{Location}, got #{loc.inspect}:#{loc.class}"
32
- end
29
+ raise TypeError, "expected #{Location}, got #{loc.inspect}:#{loc.class}" unless loc.is_a?(Location)
33
30
 
34
- @bridge.setLocation loc.latitude, loc.longitude, loc.altitude
31
+ @bridge.set_location loc.latitude, loc.longitude, loc.altitude
35
32
  end
36
33
 
37
34
  def set_location(lat, lon, alt)
38
35
  self.location = Location.new(Float(lat), Float(lon), Float(alt))
39
36
  end
40
-
41
- end #HasLocation
37
+ end # HasLocation
42
38
  end # DriverExtensions
43
39
  end # WebDriver
44
40
  end # Selenium
@@ -0,0 +1,51 @@
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 HasNetworkConditions
24
+
25
+ #
26
+ # Returns network conditions.
27
+ #
28
+ # @return [Hash]
29
+ #
30
+
31
+ def network_conditions
32
+ @bridge.network_conditions
33
+ end
34
+
35
+ #
36
+ # Sets network conditions
37
+ #
38
+ # @param [Hash] conditions
39
+ # @option conditions [Integer] :latency
40
+ # @option conditions [Integer] :throughput
41
+ # @option conditions [Boolean] :offline
42
+ #
43
+
44
+ def network_conditions=(conditions)
45
+ @bridge.network_conditions = conditions
46
+ end
47
+
48
+ end # HasNetworkConditions
49
+ end # DriverExtensions
50
+ end # WebDriver
51
+ end # Selenium
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -22,7 +22,7 @@ module Selenium
22
22
  module DriverExtensions
23
23
  module HasNetworkConnection
24
24
  def network_connection_type
25
- connection_value = @bridge.getNetworkConnection
25
+ connection_value = @bridge.network_connection
26
26
 
27
27
  connection_type = values_to_type[connection_value]
28
28
 
@@ -32,17 +32,17 @@ module Selenium
32
32
  end
33
33
 
34
34
  def network_connection_type=(connection_type)
35
- raise ArgumentError, "Invalid connection type" unless valid_type? connection_type
35
+ raise ArgumentError, 'Invalid connection type' unless valid_type? connection_type
36
36
 
37
37
  connection_value = type_to_values[connection_type]
38
38
 
39
- @bridge.setNetworkConnection connection_value
39
+ @bridge.network_connection = connection_value
40
40
  end
41
41
 
42
42
  private
43
43
 
44
44
  def type_to_values
45
- {:airplane_mode => 1, :wifi => 2, :data => 4, :all => 6, :none => 0}
45
+ {airplane_mode: 1, wifi: 2, data: 4, all: 6, none: 0}
46
46
  end
47
47
 
48
48
  def values_to_type
@@ -50,9 +50,8 @@ module Selenium
50
50
  end
51
51
 
52
52
  def valid_type?(type)
53
- type_to_values.keys.include? type
53
+ type_to_values.key? type
54
54
  end
55
-
56
55
  end # HasNetworkConnection
57
56
  end # DriverExtensions
58
57
  end # WebDriver
@@ -0,0 +1,51 @@
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 HasPermissions
24
+
25
+ #
26
+ # Returns permissions.
27
+ #
28
+ # @return [Hash]
29
+ #
30
+
31
+ def permissions
32
+ @bridge.permissions
33
+ end
34
+
35
+ #
36
+ # Sets permissions.
37
+ #
38
+ # @example
39
+ # driver.permissions = {'getUserMedia' => true}
40
+ #
41
+ # @param [Hash<Symbol, Boolean>] permissions
42
+ #
43
+
44
+ def permissions=(permissions)
45
+ @bridge.permissions = permissions
46
+ end
47
+
48
+ end # HasPermissions
49
+ end # DriverExtensions
50
+ end # WebDriver
51
+ end # Selenium
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -21,11 +21,9 @@ module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
23
  module HasRemoteStatus
24
-
25
24
  def remote_status
26
25
  @bridge.status
27
26
  end
28
-
29
27
  end # HasRemoteStatus
30
28
  end # DriverExtensions
31
29
  end # WebDriver
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -19,14 +19,12 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
-
23
22
  #
24
23
  # @api private
25
24
  #
26
25
 
27
26
  module DriverExtensions
28
27
  module HasSessionId
29
-
30
28
  #
31
29
  # @return [String] the session id
32
30
  # @api public
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
2
- #
1
+ # frozen_string_literal: true
2
+
3
3
  # Licensed to the Software Freedom Conservancy (SFC) under one
4
4
  # or more contributor license agreements. See the NOTICE file
5
5
  # distributed with this work for additional information
@@ -20,10 +20,9 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module DriverExtensions
23
-
24
23
  module HasTouchScreen
25
24
  def touch
26
- TouchActionBuilder.new mouse, keyboard, touch_screen
25
+ TouchActionBuilder.new Mouse.new(@bridge), Keyboard.new(@bridge), touch_screen
27
26
  end
28
27
 
29
28
  private
@@ -31,7 +30,6 @@ module Selenium
31
30
  def touch_screen
32
31
  TouchScreen.new @bridge
33
32
  end
34
-
35
33
  end # HasTouchScreen
36
34
  end # DriverExtensions
37
35
  end # WebDriver