selenium-webdriver 2.45.0 → 3.142.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGES +795 -3
- data/Gemfile +2 -0
- data/{COPYING → LICENSE} +1 -3
- data/README.md +13 -9
- data/lib/selenium/server.rb +93 -71
- data/lib/selenium/webdriver/atoms/getAttribute.js +7 -0
- data/lib/selenium/webdriver/atoms/isDisplayed.js +102 -0
- data/lib/selenium/webdriver/atoms.rb +37 -0
- data/lib/selenium/webdriver/chrome/bridge.rb +47 -99
- data/lib/selenium/webdriver/chrome/driver.rb +127 -0
- data/lib/selenium/webdriver/chrome/options.rb +190 -0
- data/lib/selenium/webdriver/chrome/profile.rb +40 -20
- data/lib/selenium/webdriver/chrome/service.rb +46 -62
- data/lib/selenium/webdriver/chrome.rb +34 -6
- data/lib/selenium/webdriver/common/action_builder.rb +69 -56
- data/lib/selenium/webdriver/common/alert.rb +25 -8
- data/lib/selenium/webdriver/common/bridge_helper.rb +35 -20
- data/lib/selenium/webdriver/common/driver.rb +90 -63
- data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +45 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +50 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +42 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +26 -11
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +58 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +23 -6
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +19 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +24 -7
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +19 -3
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +23 -7
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +26 -5
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +20 -6
- data/lib/selenium/webdriver/common/element.rb +79 -37
- data/lib/selenium/webdriver/common/error.rb +282 -106
- data/lib/selenium/webdriver/common/file_reaper.rb +23 -12
- data/lib/selenium/webdriver/common/html5/local_storage.rb +29 -12
- data/lib/selenium/webdriver/common/html5/session_storage.rb +29 -12
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +29 -18
- data/lib/selenium/webdriver/common/interactions/input_device.rb +54 -0
- data/lib/selenium/webdriver/common/interactions/interaction.rb +53 -0
- data/lib/selenium/webdriver/common/interactions/interactions.rb +43 -0
- data/lib/selenium/webdriver/common/interactions/key_actions.rb +145 -0
- data/lib/selenium/webdriver/common/interactions/key_input.rb +66 -0
- data/lib/selenium/webdriver/common/interactions/none_input.rb +36 -0
- data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +363 -0
- data/lib/selenium/webdriver/common/interactions/pointer_input.rb +139 -0
- data/lib/selenium/webdriver/common/keyboard.rb +27 -12
- data/lib/selenium/webdriver/common/keys.rb +118 -81
- data/lib/selenium/webdriver/common/log_entry.rb +27 -8
- data/lib/selenium/webdriver/common/logger.rb +115 -0
- data/lib/selenium/webdriver/common/logs.rb +24 -7
- data/lib/selenium/webdriver/common/manager.rb +177 -0
- data/lib/selenium/webdriver/common/mouse.rb +29 -12
- data/lib/selenium/webdriver/common/navigation.rb +21 -4
- data/lib/selenium/webdriver/common/options.rb +43 -126
- data/lib/selenium/webdriver/common/platform.rb +101 -97
- data/lib/selenium/webdriver/common/port_prober.rb +24 -17
- data/lib/selenium/webdriver/common/profile_helper.rb +27 -11
- data/lib/selenium/webdriver/common/proxy.rb +86 -73
- data/lib/selenium/webdriver/common/search_context.rb +49 -33
- data/lib/selenium/webdriver/common/service.rb +219 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +82 -0
- data/lib/selenium/webdriver/common/socket_poller.rb +47 -26
- data/lib/selenium/webdriver/common/target_locator.rb +35 -14
- data/lib/selenium/webdriver/common/timeouts.rb +23 -6
- data/lib/selenium/webdriver/common/touch_action_builder.rb +25 -11
- data/lib/selenium/webdriver/common/touch_screen.rb +42 -24
- data/lib/selenium/webdriver/common/w3c_action_builder.rb +212 -0
- data/lib/selenium/webdriver/common/w3c_manager.rb +45 -0
- data/lib/selenium/webdriver/common/wait.rb +34 -14
- data/lib/selenium/webdriver/common/window.rb +75 -16
- data/lib/selenium/webdriver/common/zipper.rb +26 -11
- data/lib/selenium/webdriver/common.rb +40 -7
- data/lib/selenium/webdriver/edge/bridge.rb +76 -0
- data/lib/selenium/webdriver/edge/driver.rb +66 -0
- data/lib/selenium/webdriver/edge/options.rb +80 -0
- data/lib/selenium/webdriver/edge/service.rb +52 -0
- data/lib/selenium/webdriver/edge.rb +44 -0
- data/lib/selenium/webdriver/firefox/binary.rb +70 -48
- data/lib/selenium/webdriver/firefox/driver.rb +50 -0
- data/lib/selenium/webdriver/firefox/extension/prefs.json +14 -13
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/extension.rb +50 -19
- data/lib/selenium/webdriver/firefox/launcher.rb +33 -28
- data/lib/selenium/webdriver/firefox/legacy/driver.rb +83 -0
- data/lib/selenium/webdriver/firefox/marionette/bridge.rb +49 -0
- data/lib/selenium/webdriver/firefox/marionette/driver.rb +90 -0
- data/lib/selenium/webdriver/firefox/options.rb +162 -0
- data/lib/selenium/webdriver/firefox/profile.rb +66 -48
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +28 -16
- data/lib/selenium/webdriver/firefox/service.rb +52 -0
- data/lib/selenium/webdriver/firefox/util.rb +19 -2
- data/lib/selenium/webdriver/firefox.rb +46 -10
- data/lib/selenium/webdriver/ie/driver.rb +85 -0
- data/lib/selenium/webdriver/ie/options.rb +138 -0
- data/lib/selenium/webdriver/ie/service.rb +54 -0
- data/lib/selenium/webdriver/ie.rb +32 -10
- data/lib/selenium/webdriver/remote/bridge.rb +117 -572
- data/lib/selenium/webdriver/remote/capabilities.rb +116 -99
- data/lib/selenium/webdriver/remote/driver.rb +51 -0
- data/lib/selenium/webdriver/remote/http/common.rb +54 -23
- data/lib/selenium/webdriver/remote/http/curb.rb +30 -12
- data/lib/selenium/webdriver/remote/http/default.rb +85 -42
- data/lib/selenium/webdriver/remote/http/persistent.rb +29 -7
- data/lib/selenium/webdriver/remote/oss/bridge.rb +594 -0
- data/lib/selenium/webdriver/remote/oss/commands.rb +223 -0
- data/lib/selenium/webdriver/remote/response.rb +68 -30
- data/lib/selenium/webdriver/remote/server_error.rb +22 -5
- data/lib/selenium/webdriver/remote/w3c/bridge.rb +605 -0
- data/lib/selenium/webdriver/remote/w3c/capabilities.rb +310 -0
- data/lib/selenium/webdriver/remote/w3c/commands.rb +157 -0
- data/lib/selenium/webdriver/remote.rb +27 -13
- data/lib/selenium/webdriver/safari/bridge.rb +38 -107
- data/lib/selenium/webdriver/safari/driver.rb +68 -0
- data/lib/selenium/webdriver/safari/options.rb +56 -75
- data/lib/selenium/webdriver/safari/service.rb +38 -0
- data/lib/selenium/webdriver/safari.rb +49 -31
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +40 -6
- data/lib/selenium/webdriver/support/block_event_listener.rb +24 -7
- data/lib/selenium/webdriver/support/color.rb +82 -46
- data/lib/selenium/webdriver/support/escaper.rb +43 -0
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +56 -39
- data/lib/selenium/webdriver/support/select.rb +66 -89
- data/lib/selenium/webdriver/support.rb +20 -0
- data/lib/selenium/webdriver/version.rb +24 -0
- data/lib/selenium/webdriver.rb +55 -25
- data/lib/selenium-webdriver.rb +19 -0
- data/selenium-webdriver.gemspec +42 -29
- metadata +331 -260
- data/Gemfile.lock +0 -48
- data/lib/selenium/client/base.rb +0 -132
- data/lib/selenium/client/driver.rb +0 -10
- data/lib/selenium/client/errors.rb +0 -9
- data/lib/selenium/client/extensions.rb +0 -118
- data/lib/selenium/client/idiomatic.rb +0 -488
- data/lib/selenium/client/javascript_expression_builder.rb +0 -116
- data/lib/selenium/client/javascript_frameworks/jquery.rb +0 -13
- data/lib/selenium/client/javascript_frameworks/prototype.rb +0 -13
- data/lib/selenium/client/legacy_driver.rb +0 -1720
- data/lib/selenium/client/protocol.rb +0 -104
- data/lib/selenium/client/selenium_helper.rb +0 -34
- data/lib/selenium/client.rb +0 -38
- data/lib/selenium/rake/server_task.rb +0 -157
- data/lib/selenium/webdriver/android/bridge.rb +0 -49
- data/lib/selenium/webdriver/android.rb +0 -9
- data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -9
- data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -42
- data/lib/selenium/webdriver/common/core_ext/string.rb +0 -5
- data/lib/selenium/webdriver/common/driver_extensions/has_browser_connection.rb +0 -17
- data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +0 -39
- data/lib/selenium/webdriver/common/html5/location.rb +0 -0
- data/lib/selenium/webdriver/common/json_helper.rb +0 -34
- data/lib/selenium/webdriver/firefox/bridge.rb +0 -70
- data/lib/selenium/webdriver/firefox/socket_lock.rb +0 -61
- data/lib/selenium/webdriver/ie/bridge.rb +0 -69
- data/lib/selenium/webdriver/ie/server.rb +0 -90
- data/lib/selenium/webdriver/iphone/bridge.rb +0 -45
- data/lib/selenium/webdriver/iphone.rb +0 -9
- data/lib/selenium/webdriver/opera/bridge.rb +0 -112
- data/lib/selenium/webdriver/opera/service.rb +0 -49
- data/lib/selenium/webdriver/opera.rb +0 -24
- data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -59
- data/lib/selenium/webdriver/phantomjs/service.rb +0 -90
- data/lib/selenium/webdriver/phantomjs.rb +0 -22
- data/lib/selenium/webdriver/remote/commands.rb +0 -192
- data/lib/selenium/webdriver/safari/browser.rb +0 -20
- data/lib/selenium/webdriver/safari/extensions.rb +0 -170
- data/lib/selenium/webdriver/safari/resources/SafariDriver.safariextz +0 -0
- data/lib/selenium/webdriver/safari/resources/client.js +0 -6903
- data/lib/selenium/webdriver/safari/server.rb +0 -145
- 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 {
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
66
|
-
|
|
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
|
|
78
|
-
|
|
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
|
|
84
|
-
|
|
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
|
-
|
|
92
|
-
|
|
115
|
+
sleep @interval
|
|
116
|
+
end
|
|
93
117
|
|
|
94
|
-
|
|
95
|
-
sleep @interval
|
|
118
|
+
false
|
|
96
119
|
end
|
|
97
120
|
|
|
98
|
-
|
|
99
|
-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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.
|
|
69
|
+
@bridge.switch_to_window id
|
|
48
70
|
|
|
49
71
|
begin
|
|
50
72
|
returned = yield
|
|
51
73
|
ensure
|
|
52
|
-
current_handles = @bridge.
|
|
74
|
+
current_handles = @bridge.window_handles
|
|
53
75
|
original = current_handles.first unless current_handles.include? original
|
|
54
|
-
@bridge.
|
|
76
|
+
@bridge.switch_to_window original
|
|
55
77
|
returned
|
|
56
78
|
end
|
|
57
79
|
else
|
|
58
|
-
@bridge.
|
|
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.
|
|
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.
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
63
|
-
|
|
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 = {
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
71
|
-
|
|
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.
|
|
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
|
|
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
|
-
|
|
99
|
-
raise TypeError, "expected #{Element}, got #{element.inspect}:#{element.class}"
|
|
100
|
-
end
|
|
101
|
-
end
|
|
117
|
+
return if element.is_a? Element
|
|
102
118
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
end
|
|
119
|
+
raise TypeError, "expected #{Element}, got #{element.inspect}:#{element.class}"
|
|
120
|
+
end
|
|
121
|
+
end # TouchScreen
|
|
122
|
+
end # WebDriver
|
|
123
|
+
end # Selenium
|