selenium-webdriver 3.0.0.beta4.0 → 4.0.0.alpha5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +679 -0
  3. data/Gemfile +2 -0
  4. data/LICENSE +1 -1
  5. data/README.md +1 -1
  6. data/lib/selenium-webdriver.rb +2 -2
  7. data/lib/selenium/server.rb +23 -16
  8. data/lib/selenium/webdriver.rb +43 -25
  9. data/lib/selenium/webdriver/atoms.rb +20 -1
  10. data/lib/selenium/webdriver/atoms/findElements.js +122 -0
  11. data/lib/selenium/webdriver/atoms/getAttribute.js +84 -11
  12. data/lib/selenium/webdriver/atoms/isDisplayed.js +100 -0
  13. data/lib/selenium/webdriver/chrome.rb +15 -20
  14. data/lib/selenium/webdriver/chrome/bridge.rb +29 -66
  15. data/lib/selenium/webdriver/{edge/service.rb → chrome/driver.rb} +19 -22
  16. data/lib/selenium/webdriver/chrome/options.rb +221 -0
  17. data/lib/selenium/webdriver/chrome/profile.rb +6 -7
  18. data/lib/selenium/webdriver/chrome/service.rb +20 -20
  19. data/lib/selenium/webdriver/common.rb +19 -11
  20. data/lib/selenium/webdriver/common/action_builder.rb +98 -246
  21. data/lib/selenium/webdriver/common/alert.rb +2 -7
  22. data/lib/selenium/webdriver/common/driver.rb +89 -51
  23. data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +45 -0
  24. data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +50 -0
  25. data/lib/selenium/webdriver/common/driver_extensions/{has_input_devices.rb → has_debugger.rb} +12 -25
  26. data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +38 -0
  27. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +3 -5
  28. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +51 -0
  29. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +3 -3
  30. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +51 -0
  31. data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +2 -2
  32. data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +2 -2
  33. data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +2 -2
  34. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +4 -4
  35. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +9 -3
  36. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +3 -5
  37. data/lib/selenium/webdriver/common/element.rb +32 -10
  38. data/lib/selenium/webdriver/common/error.rb +103 -121
  39. data/lib/selenium/webdriver/common/file_reaper.rb +3 -5
  40. data/lib/selenium/webdriver/common/html5/local_storage.rb +2 -2
  41. data/lib/selenium/webdriver/common/html5/session_storage.rb +2 -2
  42. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +3 -2
  43. data/lib/selenium/webdriver/common/interactions/input_device.rb +54 -0
  44. data/lib/selenium/webdriver/common/interactions/interaction.rb +53 -0
  45. data/lib/selenium/webdriver/{phantomjs.rb → common/interactions/interactions.rb} +17 -20
  46. data/lib/selenium/webdriver/common/interactions/key_actions.rb +145 -0
  47. data/lib/selenium/webdriver/common/interactions/key_input.rb +66 -0
  48. data/lib/selenium/webdriver/common/interactions/none_input.rb +36 -0
  49. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +363 -0
  50. data/lib/selenium/webdriver/common/interactions/pointer_input.rb +139 -0
  51. data/lib/selenium/webdriver/common/keys.rb +37 -15
  52. data/lib/selenium/webdriver/common/log_entry.rb +4 -4
  53. data/lib/selenium/webdriver/common/logger.rb +147 -0
  54. data/lib/selenium/webdriver/common/logs.rb +2 -2
  55. data/lib/selenium/webdriver/common/manager.rb +177 -0
  56. data/lib/selenium/webdriver/common/navigation.rb +2 -2
  57. data/lib/selenium/webdriver/common/options.rb +47 -105
  58. data/lib/selenium/webdriver/common/platform.rb +44 -38
  59. data/lib/selenium/webdriver/common/port_prober.rb +8 -19
  60. data/lib/selenium/webdriver/common/profile_helper.rb +13 -5
  61. data/lib/selenium/webdriver/common/proxy.rb +14 -8
  62. data/lib/selenium/webdriver/common/search_context.rb +16 -20
  63. data/lib/selenium/webdriver/common/service.rb +115 -30
  64. data/lib/selenium/webdriver/common/socket_lock.rb +12 -7
  65. data/lib/selenium/webdriver/common/socket_poller.rb +29 -22
  66. data/lib/selenium/webdriver/common/target_locator.rb +6 -6
  67. data/lib/selenium/webdriver/common/timeouts.rb +2 -2
  68. data/lib/selenium/webdriver/common/wait.rb +14 -8
  69. data/lib/selenium/webdriver/common/window.rb +38 -2
  70. data/lib/selenium/webdriver/common/zipper.rb +3 -5
  71. data/lib/selenium/webdriver/edge.rb +33 -20
  72. data/lib/selenium/webdriver/edge_chrome/bridge.rb +30 -0
  73. data/lib/selenium/webdriver/edge_chrome/driver.rb +38 -0
  74. data/lib/selenium/webdriver/{common/driver_extensions/has_touch_screen.rb → edge_chrome/options.rb} +10 -12
  75. data/lib/selenium/webdriver/edge_chrome/profile.rb +33 -0
  76. data/lib/selenium/webdriver/edge_chrome/service.rb +36 -0
  77. data/lib/selenium/webdriver/edge_html/driver.rb +39 -0
  78. data/lib/selenium/webdriver/edge_html/options.rb +91 -0
  79. data/lib/selenium/webdriver/edge_html/service.rb +47 -0
  80. data/lib/selenium/webdriver/firefox.rb +24 -29
  81. data/lib/selenium/webdriver/firefox/bridge.rb +15 -39
  82. data/lib/selenium/webdriver/firefox/{util.rb → driver.rb} +13 -19
  83. data/lib/selenium/webdriver/firefox/extension.rb +28 -8
  84. data/lib/selenium/webdriver/firefox/options.rb +162 -0
  85. data/lib/selenium/webdriver/firefox/profile.rb +23 -82
  86. data/lib/selenium/webdriver/firefox/profiles_ini.rb +5 -5
  87. data/lib/selenium/webdriver/firefox/service.rb +18 -37
  88. data/lib/selenium/webdriver/ie.rb +13 -19
  89. data/lib/selenium/webdriver/ie/driver.rb +40 -0
  90. data/lib/selenium/webdriver/ie/options.rb +118 -0
  91. data/lib/selenium/webdriver/ie/service.rb +20 -20
  92. data/lib/selenium/webdriver/remote.rb +15 -17
  93. data/lib/selenium/webdriver/remote/bridge.rb +281 -300
  94. data/lib/selenium/webdriver/remote/capabilities.rb +102 -83
  95. data/lib/selenium/webdriver/remote/commands.rb +132 -192
  96. data/lib/selenium/webdriver/remote/driver.rb +52 -0
  97. data/lib/selenium/webdriver/remote/http/common.rb +23 -13
  98. data/lib/selenium/webdriver/remote/http/curb.rb +10 -7
  99. data/lib/selenium/webdriver/remote/http/default.rb +52 -32
  100. data/lib/selenium/webdriver/remote/http/persistent.rb +8 -4
  101. data/lib/selenium/webdriver/remote/response.rb +32 -35
  102. data/lib/selenium/webdriver/remote/server_error.rb +2 -2
  103. data/lib/selenium/webdriver/safari.rb +24 -22
  104. data/lib/selenium/webdriver/safari/bridge.rb +21 -21
  105. data/lib/selenium/webdriver/safari/driver.rb +41 -0
  106. data/lib/selenium/webdriver/safari/options.rb +66 -0
  107. data/lib/selenium/webdriver/safari/service.rb +8 -24
  108. data/lib/selenium/webdriver/support.rb +3 -2
  109. data/lib/selenium/webdriver/support/abstract_event_listener.rb +2 -2
  110. data/lib/selenium/webdriver/support/block_event_listener.rb +3 -3
  111. data/lib/selenium/webdriver/support/color.rb +13 -13
  112. data/lib/selenium/webdriver/support/escaper.rb +2 -2
  113. data/lib/selenium/webdriver/support/event_firing_bridge.rb +4 -4
  114. data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
  115. data/lib/selenium/webdriver/support/select.rb +20 -21
  116. data/lib/selenium/webdriver/version.rb +24 -0
  117. data/selenium-webdriver.gemspec +31 -17
  118. metadata +331 -248
  119. data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
  120. data/lib/selenium/webdriver/common/keyboard.rb +0 -69
  121. data/lib/selenium/webdriver/common/mouse.rb +0 -88
  122. data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -81
  123. data/lib/selenium/webdriver/common/touch_screen.rb +0 -121
  124. data/lib/selenium/webdriver/common/w3c_error.rb +0 -191
  125. data/lib/selenium/webdriver/edge/bridge.rb +0 -76
  126. data/lib/selenium/webdriver/edge/legacy_support.rb +0 -117
  127. data/lib/selenium/webdriver/firefox/binary.rb +0 -186
  128. data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
  129. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  130. data/lib/selenium/webdriver/firefox/launcher.rb +0 -114
  131. data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
  132. data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
  133. data/lib/selenium/webdriver/firefox/w3c_bridge.rb +0 -79
  134. data/lib/selenium/webdriver/ie/bridge.rb +0 -76
  135. data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -65
  136. data/lib/selenium/webdriver/phantomjs/service.rb +0 -66
  137. data/lib/selenium/webdriver/remote/w3c_bridge.rb +0 -682
  138. data/lib/selenium/webdriver/remote/w3c_capabilities.rb +0 -228
  139. data/lib/selenium/webdriver/remote/w3c_commands.rb +0 -135
@@ -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
@@ -42,11 +42,6 @@ module Selenium
42
42
  def text
43
43
  @bridge.alert_text
44
44
  end
45
-
46
- def authenticate(username, password)
47
- @bridge.authentication(username: username, password: password)
48
- accept
49
- end
50
45
  end # Alert
51
46
  end # WebDriver
52
47
  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
@@ -41,38 +41,26 @@ module Selenium
41
41
  #
42
42
 
43
43
  def for(browser, opts = {})
44
- listener = opts.delete(:listener)
45
-
46
- bridge = case browser
47
- when :firefox, :ff
48
- if Remote::W3CCapabilities.w3c?(opts)
49
- Firefox::W3CBridge.new(opts)
50
- else
51
- Firefox::Bridge.new(opts)
52
- end
53
- when :remote
54
- if Remote::W3CCapabilities.w3c?(opts)
55
- Remote::W3CBridge.new(opts)
56
- else
57
- Remote::Bridge.new(opts)
58
- end
59
- when :ie, :internet_explorer
60
- IE::Bridge.new(opts)
61
- when :chrome
62
- Chrome::Bridge.new(opts)
63
- when :edge
64
- Edge::Bridge.new(opts)
65
- when :phantomjs
66
- PhantomJS::Bridge.new(opts)
67
- when :safari
68
- Safari::Bridge.new(opts)
69
- else
70
- raise ArgumentError, "unknown driver: #{browser.inspect}"
71
- end
72
-
73
- bridge = Support::EventFiringBridge.new(bridge, listener) if listener
74
-
75
- 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 :firefox, :ff
52
+ Firefox::Driver.new(opts)
53
+ when :edge
54
+ Edge::Driver.new(opts)
55
+ when :edge_chrome
56
+ EdgeChrome::Driver.new(opts)
57
+ when :edge_html
58
+ EdgeHtml::Driver.new(opts)
59
+ when :remote
60
+ Remote::Driver.new(opts)
61
+ else
62
+ raise ArgumentError, "unknown driver: #{browser.inspect}"
63
+ end
76
64
  end
77
65
  end
78
66
 
@@ -83,16 +71,14 @@ module Selenium
83
71
  # @api private
84
72
  #
85
73
 
86
- def initialize(bridge)
87
- @bridge = bridge
88
-
89
- # TODO: refactor this away
90
- return if bridge.driver_extensions.empty?
91
- extend(*bridge.driver_extensions)
74
+ def initialize(bridge: nil, listener: nil, **opts)
75
+ @service = nil
76
+ bridge ||= create_bridge(opts)
77
+ @bridge = listener ? Support::EventFiringBridge.new(bridge, listener) : bridge
92
78
  end
93
79
 
94
80
  def inspect
95
- format '#<%s:0x%x browser=%s>', self.class, hash * 2, bridge.browser.inspect
81
+ format '#<%<class>s:0x%<hash>x browser=%<browser>s>', class: self.class, hash: hash * 2, browser: bridge.browser.inspect
96
82
  end
97
83
 
98
84
  #
@@ -114,12 +100,29 @@ module Selenium
114
100
  end
115
101
 
116
102
  #
117
- # @return [Options]
118
- # @see Options
103
+ # @return [Manager]
104
+ # @see Manager
119
105
  #
120
106
 
121
107
  def manage
122
- @manage ||= WebDriver::Options.new(bridge)
108
+ bridge.manage
109
+ end
110
+
111
+ #
112
+ # @return [ActionBuilder]
113
+ # @see ActionBuilder
114
+ #
115
+
116
+ def action
117
+ bridge.action
118
+ end
119
+
120
+ def mouse
121
+ bridge.mouse
122
+ end
123
+
124
+ def keyboard
125
+ bridge.keyboard
123
126
  end
124
127
 
125
128
  #
@@ -166,6 +169,8 @@ module Selenium
166
169
 
167
170
  def quit
168
171
  bridge.quit
172
+ ensure
173
+ @service&.stop
169
174
  end
170
175
 
171
176
  #
@@ -202,7 +207,7 @@ module Selenium
202
207
  #
203
208
  # @param [String] script
204
209
  # JavaScript source to execute
205
- # @param [WebDriver::Element,Integer, Float, Boolean, NilClass, String, Array] *args
210
+ # @param [WebDriver::Element, Integer, Float, Boolean, NilClass, String, Array] args
206
211
  # Arguments will be available in the given script in the 'arguments' pseudo-array.
207
212
  #
208
213
  # @return [WebDriver::Element,Integer,Float,Boolean,NilClass,String,Array]
@@ -222,7 +227,7 @@ module Selenium
222
227
  #
223
228
  # @param [String] script
224
229
  # JavaScript source to execute
225
- # @param [WebDriver::Element,Integer, Float, Boolean, NilClass, String, Array] *args
230
+ # @param [WebDriver::Element,Integer, Float, Boolean, NilClass, String, Array] args
226
231
  # Arguments to the script. May be empty.
227
232
  #
228
233
  # @return [WebDriver::Element,Integer,Float,Boolean,NilClass,String,Array]
@@ -255,7 +260,7 @@ module Selenium
255
260
  # Get the first element matching the given selector. If given a
256
261
  # String or Symbol, it will be used as the id of the element.
257
262
  #
258
- # @param [String,Hash] id or selector
263
+ # @param [String,Hash] sel id or selector
259
264
  # @return [WebDriver::Element]
260
265
  #
261
266
  # Examples:
@@ -271,7 +276,7 @@ module Selenium
271
276
  end
272
277
 
273
278
  def browser
274
- bridge.browser
279
+ bridge&.browser
275
280
  end
276
281
 
277
282
  def capabilities
@@ -283,13 +288,46 @@ module Selenium
283
288
  # @see SearchContext
284
289
  #
285
290
 
286
- def ref
287
- nil
288
- end
291
+ def ref; end
289
292
 
290
293
  private
291
294
 
292
295
  attr_reader :bridge
296
+
297
+ def create_bridge(**opts)
298
+ opts[:url] ||= service_url(opts)
299
+
300
+ desired_capabilities = opts.delete(:desired_capabilities) || Remote::Capabilities.send(browser || :new)
301
+ options = opts.delete(:options)
302
+
303
+ bridge = Remote::Bridge.new(http_client: opts.delete(:http_client), url: opts.delete(:url))
304
+ raise ArgumentError, "Unable to create a driver with parameters: #{opts}" unless opts.empty?
305
+
306
+ namespacing = self.class.to_s.split('::')
307
+
308
+ if Object.const_defined?("#{namespacing[0..-2].join('::')}::Bridge") && !namespacing.include?('Remote')
309
+ bridge.extend Object.const_get("#{namespacing[0, namespacing.length - 1].join('::')}::Bridge")
310
+ end
311
+
312
+ bridge.create_session(desired_capabilities, options)
313
+ bridge
314
+ end
315
+
316
+ def service_url(opts)
317
+ @service = opts.delete(:service)
318
+ %i[driver_opts driver_path port].each do |key|
319
+ next unless opts.key? key
320
+
321
+ WebDriver.logger.deprecate(":#{key}", ':service with an instance of Selenium::WebDriver::Service',
322
+ id: "service_#{key}".to_sym)
323
+ end
324
+ @service ||= Service.send(browser,
325
+ args: opts.delete(:driver_opts),
326
+ path: opts.delete(:driver_path),
327
+ port: opts.delete(:port))
328
+ @service.start
329
+ @service.uri
330
+ end
293
331
  end # Driver
294
332
  end # WebDriver
295
333
  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,37 +19,24 @@
19
19
 
20
20
  module Selenium
21
21
  module WebDriver
22
- #
23
- # @api private
24
- #
25
-
26
22
  module DriverExtensions
27
- module HasInputDevices
28
- #
29
- # @return [ActionBuilder]
30
- # @api public
31
- #
32
-
33
- def action
34
- ActionBuilder.new mouse, keyboard
35
- end
23
+ module HasDebugger
36
24
 
37
25
  #
38
- # @api private
26
+ # Attaches debugger to session.
39
27
  #
40
-
41
- def mouse
42
- Mouse.new @bridge
43
- end
44
-
28
+ # @example
29
+ # driver.attach_debugger
30
+ # driver.execute_script('debugger')
45
31
  #
46
- # @api private
32
+ # @return [Hash]
47
33
  #
48
34
 
49
- def keyboard
50
- Keyboard.new @bridge
35
+ def attach_debugger
36
+ @bridge.attach_debugger
51
37
  end
52
- end # HasInputDevices
38
+
39
+ end # HasDebugger
53
40
  end # DriverExtensions
54
41
  end # WebDriver
55
42
  end # Selenium
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to the Software Freedom Conservancy (SFC) under one
4
+ # or more contributor license agreements. See the NOTICE file
5
+ # distributed with this work for additional information
6
+ # regarding copyright ownership. The SFC licenses this file
7
+ # to you under the Apache License, Version 2.0 (the
8
+ # "License"); you may not use this file except in compliance
9
+ # with the License. You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing,
14
+ # software distributed under the License is distributed on an
15
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16
+ # KIND, either express or implied. See the License for the
17
+ # specific language governing permissions and limitations
18
+ # under the License.
19
+
20
+ module Selenium
21
+ module WebDriver
22
+ module DriverExtensions
23
+ module HasDevTools
24
+
25
+ #
26
+ # Retrieves connection to DevTools.
27
+ #
28
+ # @return [DevTools]
29
+ #
30
+
31
+ def devtools
32
+ @devtools ||= DevTools.new(capabilities['goog:chromeOptions']['debuggerAddress'])
33
+ end
34
+
35
+ end # HasDevTools
36
+ end # DriverExtensions
37
+ end # WebDriver
38
+ 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
@@ -26,9 +26,7 @@ module Selenium
26
26
  end
27
27
 
28
28
  def location=(loc)
29
- unless loc.is_a?(Location)
30
- raise TypeError, "expected #{Location}, got #{loc.inspect}:#{loc.class}"
31
- end
29
+ raise TypeError, "expected #{Location}, got #{loc.inspect}:#{loc.class}" unless loc.is_a?(Location)
32
30
 
33
31
  @bridge.set_location loc.latitude, loc.longitude, loc.altitude
34
32
  end
@@ -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