selenium-webdriver 2.45.0 → 3.142.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +795 -3
  3. data/Gemfile +2 -0
  4. data/{COPYING → LICENSE} +1 -3
  5. data/README.md +13 -9
  6. data/lib/selenium/server.rb +93 -71
  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/atoms.rb +37 -0
  10. data/lib/selenium/webdriver/chrome/bridge.rb +47 -99
  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 +40 -20
  14. data/lib/selenium/webdriver/chrome/service.rb +46 -62
  15. data/lib/selenium/webdriver/chrome.rb +34 -6
  16. data/lib/selenium/webdriver/common/action_builder.rb +69 -56
  17. data/lib/selenium/webdriver/common/alert.rb +25 -8
  18. data/lib/selenium/webdriver/common/bridge_helper.rb +35 -20
  19. data/lib/selenium/webdriver/common/driver.rb +90 -63
  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_debugger.rb +42 -0
  23. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +26 -11
  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 +58 -0
  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 +23 -6
  28. data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +19 -2
  29. data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +24 -7
  30. data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +19 -3
  31. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +23 -7
  32. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +26 -5
  33. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +20 -6
  34. data/lib/selenium/webdriver/common/element.rb +79 -37
  35. data/lib/selenium/webdriver/common/error.rb +282 -106
  36. data/lib/selenium/webdriver/common/file_reaper.rb +23 -12
  37. data/lib/selenium/webdriver/common/html5/local_storage.rb +29 -12
  38. data/lib/selenium/webdriver/common/html5/session_storage.rb +29 -12
  39. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +29 -18
  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/common/interactions/interactions.rb +43 -0
  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/common/interactions/none_input.rb +36 -0
  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 +27 -12
  49. data/lib/selenium/webdriver/common/keys.rb +118 -81
  50. data/lib/selenium/webdriver/common/log_entry.rb +27 -8
  51. data/lib/selenium/webdriver/common/logger.rb +115 -0
  52. data/lib/selenium/webdriver/common/logs.rb +24 -7
  53. data/lib/selenium/webdriver/common/manager.rb +177 -0
  54. data/lib/selenium/webdriver/common/mouse.rb +29 -12
  55. data/lib/selenium/webdriver/common/navigation.rb +21 -4
  56. data/lib/selenium/webdriver/common/options.rb +43 -126
  57. data/lib/selenium/webdriver/common/platform.rb +101 -97
  58. data/lib/selenium/webdriver/common/port_prober.rb +24 -17
  59. data/lib/selenium/webdriver/common/profile_helper.rb +27 -11
  60. data/lib/selenium/webdriver/common/proxy.rb +86 -73
  61. data/lib/selenium/webdriver/common/search_context.rb +49 -33
  62. data/lib/selenium/webdriver/common/service.rb +219 -0
  63. data/lib/selenium/webdriver/common/socket_lock.rb +82 -0
  64. data/lib/selenium/webdriver/common/socket_poller.rb +47 -26
  65. data/lib/selenium/webdriver/common/target_locator.rb +35 -14
  66. data/lib/selenium/webdriver/common/timeouts.rb +23 -6
  67. data/lib/selenium/webdriver/common/touch_action_builder.rb +25 -11
  68. data/lib/selenium/webdriver/common/touch_screen.rb +42 -24
  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 +34 -14
  72. data/lib/selenium/webdriver/common/window.rb +75 -16
  73. data/lib/selenium/webdriver/common/zipper.rb +26 -11
  74. data/lib/selenium/webdriver/common.rb +40 -7
  75. data/lib/selenium/webdriver/edge/bridge.rb +76 -0
  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 +52 -0
  79. data/lib/selenium/webdriver/edge.rb +44 -0
  80. data/lib/selenium/webdriver/firefox/binary.rb +70 -48
  81. data/lib/selenium/webdriver/firefox/driver.rb +50 -0
  82. data/lib/selenium/webdriver/firefox/extension/prefs.json +14 -13
  83. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  84. data/lib/selenium/webdriver/firefox/extension.rb +50 -19
  85. data/lib/selenium/webdriver/firefox/launcher.rb +33 -28
  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 +66 -48
  91. data/lib/selenium/webdriver/firefox/profiles_ini.rb +28 -16
  92. data/lib/selenium/webdriver/firefox/service.rb +52 -0
  93. data/lib/selenium/webdriver/firefox/util.rb +19 -2
  94. data/lib/selenium/webdriver/firefox.rb +46 -10
  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 +32 -10
  99. data/lib/selenium/webdriver/remote/bridge.rb +117 -572
  100. data/lib/selenium/webdriver/remote/capabilities.rb +116 -99
  101. data/lib/selenium/webdriver/remote/driver.rb +51 -0
  102. data/lib/selenium/webdriver/remote/http/common.rb +54 -23
  103. data/lib/selenium/webdriver/remote/http/curb.rb +30 -12
  104. data/lib/selenium/webdriver/remote/http/default.rb +85 -42
  105. data/lib/selenium/webdriver/remote/http/persistent.rb +29 -7
  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 +68 -30
  109. data/lib/selenium/webdriver/remote/server_error.rb +22 -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 +27 -13
  114. data/lib/selenium/webdriver/safari/bridge.rb +38 -107
  115. data/lib/selenium/webdriver/safari/driver.rb +68 -0
  116. data/lib/selenium/webdriver/safari/options.rb +56 -75
  117. data/lib/selenium/webdriver/safari/service.rb +38 -0
  118. data/lib/selenium/webdriver/safari.rb +49 -31
  119. data/lib/selenium/webdriver/support/abstract_event_listener.rb +40 -6
  120. data/lib/selenium/webdriver/support/block_event_listener.rb +24 -7
  121. data/lib/selenium/webdriver/support/color.rb +82 -46
  122. data/lib/selenium/webdriver/support/escaper.rb +43 -0
  123. data/lib/selenium/webdriver/support/event_firing_bridge.rb +56 -39
  124. data/lib/selenium/webdriver/support/select.rb +66 -89
  125. data/lib/selenium/webdriver/support.rb +20 -0
  126. data/lib/selenium/webdriver/version.rb +24 -0
  127. data/lib/selenium/webdriver.rb +55 -25
  128. data/lib/selenium-webdriver.rb +19 -0
  129. data/selenium-webdriver.gemspec +42 -29
  130. metadata +331 -260
  131. data/Gemfile.lock +0 -48
  132. data/lib/selenium/client/base.rb +0 -132
  133. data/lib/selenium/client/driver.rb +0 -10
  134. data/lib/selenium/client/errors.rb +0 -9
  135. data/lib/selenium/client/extensions.rb +0 -118
  136. data/lib/selenium/client/idiomatic.rb +0 -488
  137. data/lib/selenium/client/javascript_expression_builder.rb +0 -116
  138. data/lib/selenium/client/javascript_frameworks/jquery.rb +0 -13
  139. data/lib/selenium/client/javascript_frameworks/prototype.rb +0 -13
  140. data/lib/selenium/client/legacy_driver.rb +0 -1720
  141. data/lib/selenium/client/protocol.rb +0 -104
  142. data/lib/selenium/client/selenium_helper.rb +0 -34
  143. data/lib/selenium/client.rb +0 -38
  144. data/lib/selenium/rake/server_task.rb +0 -157
  145. data/lib/selenium/webdriver/android/bridge.rb +0 -49
  146. data/lib/selenium/webdriver/android.rb +0 -9
  147. data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -9
  148. data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -42
  149. data/lib/selenium/webdriver/common/core_ext/string.rb +0 -5
  150. data/lib/selenium/webdriver/common/driver_extensions/has_browser_connection.rb +0 -17
  151. data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +0 -39
  152. data/lib/selenium/webdriver/common/html5/location.rb +0 -0
  153. data/lib/selenium/webdriver/common/json_helper.rb +0 -34
  154. data/lib/selenium/webdriver/firefox/bridge.rb +0 -70
  155. data/lib/selenium/webdriver/firefox/socket_lock.rb +0 -61
  156. data/lib/selenium/webdriver/ie/bridge.rb +0 -69
  157. data/lib/selenium/webdriver/ie/server.rb +0 -90
  158. data/lib/selenium/webdriver/iphone/bridge.rb +0 -45
  159. data/lib/selenium/webdriver/iphone.rb +0 -9
  160. data/lib/selenium/webdriver/opera/bridge.rb +0 -112
  161. data/lib/selenium/webdriver/opera/service.rb +0 -49
  162. data/lib/selenium/webdriver/opera.rb +0 -24
  163. data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -59
  164. data/lib/selenium/webdriver/phantomjs/service.rb +0 -90
  165. data/lib/selenium/webdriver/phantomjs.rb +0 -22
  166. data/lib/selenium/webdriver/remote/commands.rb +0 -192
  167. data/lib/selenium/webdriver/safari/browser.rb +0 -20
  168. data/lib/selenium/webdriver/safari/extensions.rb +0 -170
  169. data/lib/selenium/webdriver/safari/resources/SafariDriver.safariextz +0 -0
  170. data/lib/selenium/webdriver/safari/resources/client.js +0 -6903
  171. data/lib/selenium/webdriver/safari/server.rb +0 -145
  172. data/lib/selenium-client.rb +0 -2
@@ -0,0 +1,82 @@
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
+ #
23
+ # @api private
24
+ #
25
+
26
+ class SocketLock
27
+ def initialize(port, timeout)
28
+ @port = port
29
+ @timeout = timeout
30
+ end
31
+
32
+ #
33
+ # Attempt to acquire a lock on the given port. Control is yielded to an
34
+ # execution block if the lock could be successfully obtained.
35
+ #
36
+
37
+ def locked
38
+ lock
39
+
40
+ begin
41
+ yield
42
+ ensure
43
+ release
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def lock
50
+ max_time = current_time + @timeout
51
+
52
+ sleep 0.1 until can_lock? || current_time >= max_time
53
+
54
+ return if did_lock?
55
+
56
+ raise Error::WebDriverError, "unable to bind to locking port #{@port} within #{@timeout} seconds"
57
+ end
58
+
59
+ def current_time
60
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
61
+ end
62
+
63
+ def release
64
+ @server&.close
65
+ end
66
+
67
+ def can_lock?
68
+ @server = TCPServer.new(Platform.localhost, @port)
69
+ ChildProcess.close_on_exec @server
70
+
71
+ true
72
+ rescue SocketError, Errno::EADDRINUSE, Errno::EBADF => ex
73
+ WebDriver.logger.debug("#{self}: #{ex.message}")
74
+ false
75
+ end
76
+
77
+ def did_lock?
78
+ !@server.nil?
79
+ end
80
+ end # SocketLock
81
+ end # WebDriver
82
+ end # Selenium
@@ -1,10 +1,28 @@
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
+
1
20
  require 'selenium/webdriver/common/platform'
2
21
  require 'socket'
3
22
 
4
23
  module Selenium
5
24
  module WebDriver
6
25
  class SocketPoller
7
-
8
26
  def initialize(host, port, timeout = 0, interval = 0.25)
9
27
  @host = host
10
28
  @port = Integer(port)
@@ -31,18 +49,21 @@ module Selenium
31
49
  #
32
50
 
33
51
  def closed?
34
- with_timeout { not listening? }
52
+ with_timeout { !listening? }
35
53
  end
36
54
 
37
55
  private
38
56
 
39
57
  CONNECT_TIMEOUT = 5
40
58
 
41
- NOT_CONNECTED_ERRORS = [Errno::ECONNREFUSED, Errno::ENOTCONN, SocketError]
42
- NOT_CONNECTED_ERRORS << Errno::EPERM if Platform.cygwin?
59
+ NOT_CONNECTED_ERRORS = [Errno::ECONNREFUSED, Errno::ENOTCONN, SocketError].tap { |arr|
60
+ arr << Errno::EPERM if Platform.cygwin?
61
+ }.freeze
43
62
 
44
- CONNECTED_ERRORS = [Errno::EISCONN]
45
- CONNECTED_ERRORS << Errno::EINVAL if Platform.windows?
63
+ CONNECTED_ERRORS = [Errno::EISCONN].tap { |arr|
64
+ arr << Errno::EINVAL if Platform.windows?
65
+ arr << Errno::EALREADY if Platform.wsl?
66
+ }.freeze
46
67
 
47
68
  if Platform.jruby?
48
69
  # we use a plain TCPSocket here since JRuby has issues select()ing on a connecting socket
@@ -62,11 +83,8 @@ module Selenium
62
83
  begin
63
84
  sock.connect_nonblock sockaddr
64
85
  rescue Errno::EINPROGRESS
65
- if IO.select(nil, [sock], nil, CONNECT_TIMEOUT)
66
- retry
67
- else
68
- raise Errno::ECONNREFUSED
69
- end
86
+ retry if socket_writable?(sock) && conn_completed?(sock)
87
+ raise Errno::ECONNREFUSED
70
88
  rescue *CONNECTED_ERRORS
71
89
  # yay!
72
90
  end
@@ -74,32 +92,35 @@ module Selenium
74
92
  sock.close
75
93
  true
76
94
  rescue *NOT_CONNECTED_ERRORS
77
- sock.close if sock
78
- $stderr.puts [@host, @port].inspect if $DEBUG
95
+ sock&.close
96
+ WebDriver.logger.debug("polling for socket on #{[@host, @port].inspect}")
79
97
  false
80
98
  end
81
99
  end
82
100
 
83
- def with_timeout(&blk)
84
- max_time = time_now + @timeout
101
+ def socket_writable?(sock)
102
+ IO.select(nil, [sock], nil, CONNECT_TIMEOUT)
103
+ end
104
+
105
+ def conn_completed?(sock)
106
+ sock.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR).int.zero?
107
+ end
108
+
109
+ def with_timeout
110
+ max_time = current_time + @timeout
85
111
 
86
- (
112
+ until current_time > max_time
87
113
  return true if yield
88
- wait
89
- ) until time_now > max_time
90
114
 
91
- false
92
- end
115
+ sleep @interval
116
+ end
93
117
 
94
- def wait
95
- sleep @interval
118
+ false
96
119
  end
97
120
 
98
- # for testability
99
- def time_now
100
- Time.now
121
+ def current_time
122
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
101
123
  end
102
-
103
124
  end # SocketPoller
104
125
  end # WebDriver
105
126
  end # Selenium
@@ -1,7 +1,25 @@
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
+
1
20
  module Selenium
2
21
  module WebDriver
3
22
  class TargetLocator
4
-
5
23
  #
6
24
  # @api private
7
25
  #
@@ -15,7 +33,7 @@ module Selenium
15
33
  #
16
34
 
17
35
  def frame(id)
18
- @bridge.switchToFrame id
36
+ @bridge.switch_to_frame id
19
37
  end
20
38
 
21
39
  #
@@ -23,7 +41,7 @@ module Selenium
23
41
  #
24
42
 
25
43
  def parent_frame
26
- @bridge.switchToParentFrame
44
+ @bridge.switch_to_parent_frame
27
45
  end
28
46
 
29
47
  #
@@ -39,23 +57,27 @@ module Selenium
39
57
  def window(id)
40
58
  if block_given?
41
59
  original = begin
42
- @bridge.getCurrentWindowHandle
43
- rescue Error::NoSuchWindowError
44
- nil
60
+ @bridge.window_handle
61
+ rescue Error::NoSuchWindowError
62
+ nil
63
+ end
64
+
65
+ unless @bridge.window_handles.include? id
66
+ raise Error::NoSuchWindowError, "The specified identifier '#{id}' is not found in the window handle list"
45
67
  end
46
68
 
47
- @bridge.switchToWindow id
69
+ @bridge.switch_to_window id
48
70
 
49
71
  begin
50
72
  returned = yield
51
73
  ensure
52
- current_handles = @bridge.getWindowHandles
74
+ current_handles = @bridge.window_handles
53
75
  original = current_handles.first unless current_handles.include? original
54
- @bridge.switchToWindow original
76
+ @bridge.switch_to_window original
55
77
  returned
56
78
  end
57
79
  else
58
- @bridge.switchToWindow id
80
+ @bridge.switch_to_window id
59
81
  end
60
82
  end
61
83
 
@@ -66,7 +88,7 @@ module Selenium
66
88
  #
67
89
 
68
90
  def active_element
69
- @bridge.switchToActiveElement
91
+ @bridge.switch_to_active_element
70
92
  end
71
93
 
72
94
  #
@@ -74,7 +96,7 @@ module Selenium
74
96
  #
75
97
 
76
98
  def default_content
77
- @bridge.switchToDefaultContent
99
+ @bridge.switch_to_default_content
78
100
  end
79
101
 
80
102
  #
@@ -84,7 +106,6 @@ module Selenium
84
106
  def alert
85
107
  Alert.new(@bridge)
86
108
  end
87
-
88
109
  end # TargetLocator
89
110
  end # WebDriver
90
- end # Selenium
111
+ end # Selenium
@@ -1,7 +1,25 @@
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
+
1
20
  module Selenium
2
21
  module WebDriver
3
22
  class Timeouts
4
-
5
23
  def initialize(bridge)
6
24
  @bridge = bridge
7
25
  end
@@ -11,7 +29,7 @@ module Selenium
11
29
  #
12
30
 
13
31
  def implicit_wait=(seconds)
14
- @bridge.setImplicitWaitTimeout Integer(seconds * 1000)
32
+ @bridge.implicit_wait_timeout = Integer(seconds * 1000)
15
33
  end
16
34
 
17
35
  #
@@ -21,7 +39,7 @@ module Selenium
21
39
  #
22
40
 
23
41
  def script_timeout=(seconds)
24
- @bridge.setScriptTimeout Integer(seconds * 1000)
42
+ @bridge.script_timeout = Integer(seconds * 1000)
25
43
  end
26
44
 
27
45
  #
@@ -30,9 +48,8 @@ module Selenium
30
48
  #
31
49
 
32
50
  def page_load=(seconds)
33
- @bridge.setTimeout 'page load', Integer(seconds * 1000)
51
+ @bridge.timeout 'page load', Integer(seconds * 1000)
34
52
  end
35
-
36
53
  end # Timeouts
37
54
  end # WebDriver
38
- end # Selenium
55
+ end # Selenium
@@ -1,29 +1,44 @@
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
+
1
20
  module Selenium
2
21
  module WebDriver
3
22
  class TouchActionBuilder < ActionBuilder
4
-
5
23
  #
6
24
  # @api private
7
25
  #
8
26
 
9
27
  def initialize(mouse, keyboard, touch_screen)
28
+ WebDriver.logger.deprecate(self.class.name)
10
29
  super(mouse, keyboard)
11
30
  @devices[:touch_screen] = touch_screen
12
31
  end
13
32
 
14
33
  def scroll(*args)
15
- unless [2,3].include? args.size
16
- raise ArgumentError, "wrong number of arguments, expected 2..3, got #{args.size}"
17
- end
34
+ raise ArgumentError, "wrong number of arguments, expected 2..3, got #{args.size}" unless [2, 3].include? args.size
18
35
 
19
36
  @actions << [:touch_screen, :scroll, args]
20
37
  self
21
38
  end
22
39
 
23
40
  def flick(*args)
24
- unless [2,4].include? args.size
25
- raise ArgumentError, "wrong number of arguments, expected 2 or 4, got #{args.size}"
26
- end
41
+ raise ArgumentError, "wrong number of arguments, expected 2 or 4, got #{args.size}" unless [2, 4].include? args.size
27
42
 
28
43
  @actions << [:touch_screen, :flick, args]
29
44
  self
@@ -58,7 +73,6 @@ module Selenium
58
73
  @actions << [:touch_screen, :move, [x, y]]
59
74
  self
60
75
  end
61
-
62
- end
63
- end
64
- end
76
+ end # TouchActionBuilder
77
+ end # WebDriver
78
+ end # Selenium
@@ -1,8 +1,26 @@
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
+
1
20
  module Selenium
2
21
  module WebDriver
3
22
  class TouchScreen
4
- FLICK_SPEED = { :normal => 0, :fast => 1}
5
-
23
+ FLICK_SPEED = {normal: 0, fast: 1}.freeze
6
24
 
7
25
  #
8
26
  # @api private
@@ -14,43 +32,43 @@ module Selenium
14
32
 
15
33
  def single_tap(element)
16
34
  assert_element element
17
- @bridge.touchSingleTap element.ref
35
+ @bridge.touch_single_tap element.ref
18
36
  end
19
37
 
20
38
  def double_tap(element)
21
39
  assert_element element
22
- @bridge.touchDoubleTap element.ref
40
+ @bridge.touch_double_tap element.ref
23
41
  end
24
42
 
25
43
  def long_press(element)
26
44
  assert_element element
27
- @bridge.touchLongPress element.ref
45
+ @bridge.touch_long_press element.ref
28
46
  end
29
47
 
30
48
  def down(x, y = nil)
31
49
  x, y = coords_from x, y
32
- @bridge.touchDown x, y
50
+ @bridge.touch_down x, y
33
51
  end
34
52
 
35
53
  def up(x, y = nil)
36
54
  x, y = coords_from x, y
37
- @bridge.touchUp x, y
55
+ @bridge.touch_up x, y
38
56
  end
39
57
 
40
58
  def move(x, y = nil)
41
59
  x, y = coords_from x, y
42
- @bridge.touchMove x, y
60
+ @bridge.touch_move x, y
43
61
  end
44
62
 
45
63
  def scroll(*args)
46
64
  case args.size
47
65
  when 2
48
66
  x_offset, y_offset = args
49
- @bridge.touchScroll nil, Integer(x_offset), Integer(y_offset)
67
+ @bridge.touch_scroll nil, Integer(x_offset), Integer(y_offset)
50
68
  when 3
51
69
  element, x_offset, y_offset = args
52
70
  assert_element element
53
- @bridge.touchScroll element.ref, Integer(x_offset), Integer(y_offset)
71
+ @bridge.touch_scroll element.ref, Integer(x_offset), Integer(y_offset)
54
72
  else
55
73
  raise ArgumentError, "wrong number of arguments, expected 2..3, got #{args.size}"
56
74
  end
@@ -60,22 +78,22 @@ module Selenium
60
78
  case args.size
61
79
  when 2
62
80
  x_speed, y_speed = args
63
- @bridge.touchFlick Integer(x_speed), Integer(y_speed)
81
+ @bridge.touch_flick Integer(x_speed), Integer(y_speed)
64
82
  when 4
65
83
  element, xoffset, yoffset, speed = args
66
84
 
67
85
  assert_element element
68
- flick_speed = FLICK_SPEED[speed.to_sym]
69
86
 
70
- unless flick_speed
71
- raise ArgumentError, "expected one of #{FLICK_SPEED.keys.inspect}, got #{speed.inspect}"
87
+ if (speed.is_a?(String) || speed.is_a?(Symbol)) && FLICK_SPEED.key?(speed.to_sym)
88
+ WebDriver.logger.deprecate "Passing #{speed.inspect} speed",
89
+ "Integer or Selenium::WebDriver::TouchScreen::FLICK_SPEED[:#{speed}]"
90
+ speed = FLICK_SPEED[speed.to_sym]
72
91
  end
73
92
 
74
- @bridge.touchElementFlick element.ref, Integer(xoffset), Integer(yoffset), flick_speed
93
+ @bridge.touch_element_flick element.ref, Integer(xoffset), Integer(yoffset), Integer(speed)
75
94
  else
76
95
  raise ArgumentError, "wrong number of arguments, expected 2 or 4, got #{args.size}"
77
96
  end
78
-
79
97
  end
80
98
 
81
99
  private
@@ -88,18 +106,18 @@ module Selenium
88
106
  raise ArgumentError, "expected #{point.inspect} to respond to :x and :y"
89
107
  end
90
108
 
91
- x, y = point.x, point.y
109
+ x = point.x
110
+ y = point.y
92
111
  end
93
112
 
94
113
  [Integer(x), Integer(y)]
95
114
  end
96
115
 
97
116
  def assert_element(element)
98
- unless element.kind_of? Element
99
- raise TypeError, "expected #{Element}, got #{element.inspect}:#{element.class}"
100
- end
101
- end
117
+ return if element.is_a? Element
102
118
 
103
- end
104
- end
105
- end
119
+ raise TypeError, "expected #{Element}, got #{element.inspect}:#{element.class}"
120
+ end
121
+ end # TouchScreen
122
+ end # WebDriver
123
+ end # Selenium