selenium-webdriver 2.53.3 → 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 +665 -8
- data/Gemfile +2 -0
- data/LICENSE +1 -1
- data/README.md +2 -3
- data/lib/selenium/server.rb +76 -73
- data/lib/selenium/webdriver/atoms/getAttribute.js +7 -0
- data/lib/selenium/webdriver/atoms/isDisplayed.js +102 -0
- data/lib/selenium/webdriver/{phantomjs.rb → atoms.rb} +10 -14
- data/lib/selenium/webdriver/chrome/bridge.rb +30 -101
- 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 +21 -20
- data/lib/selenium/webdriver/chrome/service.rb +26 -93
- data/lib/selenium/webdriver/chrome.rb +15 -6
- data/lib/selenium/webdriver/common/action_builder.rb +52 -58
- data/lib/selenium/webdriver/common/alert.rb +7 -15
- data/lib/selenium/webdriver/common/bridge_helper.rb +18 -22
- data/lib/selenium/webdriver/common/driver.rb +72 -72
- 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_input_devices.rb → has_debugger.rb} +11 -27
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +6 -10
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +7 -8
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +2 -4
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +2 -4
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +3 -5
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +2 -5
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +6 -9
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +9 -7
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +3 -8
- data/lib/selenium/webdriver/common/element.rb +59 -39
- data/lib/selenium/webdriver/common/error.rb +259 -104
- data/lib/selenium/webdriver/common/file_reaper.rb +6 -14
- data/lib/selenium/webdriver/common/html5/local_storage.rb +8 -10
- data/lib/selenium/webdriver/common/html5/session_storage.rb +8 -10
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +8 -16
- 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/{safari/browser.rb → common/interactions/interactions.rb} +17 -14
- 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/{android.rb → common/interactions/none_input.rb} +14 -6
- 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 +10 -14
- data/lib/selenium/webdriver/common/keys.rb +102 -82
- data/lib/selenium/webdriver/common/log_entry.rb +7 -8
- data/lib/selenium/webdriver/common/logger.rb +115 -0
- data/lib/selenium/webdriver/common/logs.rb +4 -6
- data/lib/selenium/webdriver/common/manager.rb +177 -0
- data/lib/selenium/webdriver/common/mouse.rb +12 -14
- data/lib/selenium/webdriver/common/navigation.rb +4 -6
- data/lib/selenium/webdriver/common/options.rb +26 -127
- data/lib/selenium/webdriver/common/platform.rb +75 -101
- data/lib/selenium/webdriver/common/port_prober.rb +7 -19
- data/lib/selenium/webdriver/common/profile_helper.rb +8 -11
- data/lib/selenium/webdriver/common/proxy.rb +68 -74
- data/lib/selenium/webdriver/common/search_context.rb +28 -37
- data/lib/selenium/webdriver/common/service.rb +219 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +15 -16
- data/lib/selenium/webdriver/common/socket_poller.rb +30 -28
- data/lib/selenium/webdriver/common/target_locator.rb +16 -18
- data/lib/selenium/webdriver/common/timeouts.rb +6 -8
- data/lib/selenium/webdriver/common/touch_action_builder.rb +5 -10
- data/lib/selenium/webdriver/common/touch_screen.rb +22 -23
- 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 +17 -16
- data/lib/selenium/webdriver/common/window.rb +50 -17
- data/lib/selenium/webdriver/common/zipper.rb +9 -13
- data/lib/selenium/webdriver/common.rb +21 -7
- data/lib/selenium/webdriver/edge/bridge.rb +34 -63
- 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 +23 -95
- data/lib/selenium/webdriver/edge.rb +13 -13
- data/lib/selenium/webdriver/firefox/binary.rb +45 -60
- data/lib/selenium/webdriver/firefox/driver.rb +50 -0
- data/lib/selenium/webdriver/firefox/extension/prefs.json +3 -12
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/extension.rb +20 -10
- data/lib/selenium/webdriver/firefox/launcher.rb +16 -22
- 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 +47 -48
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +11 -18
- data/lib/selenium/webdriver/firefox/service.rb +24 -95
- data/lib/selenium/webdriver/firefox/util.rb +2 -4
- data/lib/selenium/webdriver/firefox.rb +27 -12
- 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 +12 -10
- data/lib/selenium/webdriver/remote/bridge.rb +100 -564
- data/lib/selenium/webdriver/remote/capabilities.rb +98 -100
- data/lib/selenium/webdriver/remote/driver.rb +51 -0
- data/lib/selenium/webdriver/remote/http/common.rb +34 -22
- data/lib/selenium/webdriver/remote/http/curb.rb +13 -14
- data/lib/selenium/webdriver/remote/http/default.rb +62 -43
- data/lib/selenium/webdriver/remote/http/persistent.rb +12 -9
- 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 +48 -28
- data/lib/selenium/webdriver/remote/server_error.rb +3 -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 +10 -16
- data/lib/selenium/webdriver/safari/bridge.rb +17 -101
- data/lib/selenium/webdriver/{firefox/w3c_bridge.rb → safari/driver.rb} +27 -25
- data/lib/selenium/webdriver/safari/options.rb +29 -31
- data/lib/selenium/webdriver/safari/service.rb +38 -0
- data/lib/selenium/webdriver/safari.rb +27 -27
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +19 -4
- data/lib/selenium/webdriver/support/block_event_listener.rb +3 -5
- data/lib/selenium/webdriver/support/color.rb +60 -43
- data/lib/selenium/webdriver/support/escaper.rb +43 -0
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +39 -41
- data/lib/selenium/webdriver/support/select.rb +45 -97
- data/lib/selenium/webdriver/support.rb +3 -2
- data/lib/selenium/webdriver/{iphone.rb → version.rb} +3 -7
- data/lib/selenium/webdriver.rb +36 -23
- data/lib/selenium-webdriver.rb +2 -2
- data/selenium-webdriver.gemspec +42 -29
- metadata +331 -262
- data/lib/selenium/client/base.rb +0 -151
- data/lib/selenium/client/driver.rb +0 -29
- data/lib/selenium/client/errors.rb +0 -28
- data/lib/selenium/client/extensions.rb +0 -132
- data/lib/selenium/client/idiomatic.rb +0 -507
- data/lib/selenium/client/javascript_expression_builder.rb +0 -135
- data/lib/selenium/client/javascript_frameworks/jquery.rb +0 -32
- data/lib/selenium/client/javascript_frameworks/prototype.rb +0 -32
- data/lib/selenium/client/legacy_driver.rb +0 -1722
- data/lib/selenium/client/protocol.rb +0 -123
- data/lib/selenium/client/selenium_helper.rb +0 -49
- data/lib/selenium/client.rb +0 -57
- data/lib/selenium/rake/server_task.rb +0 -176
- data/lib/selenium/webdriver/android/bridge.rb +0 -68
- data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -28
- data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -61
- data/lib/selenium/webdriver/common/html5/location.rb +0 -19
- data/lib/selenium/webdriver/common/w3c_error.rb +0 -194
- data/lib/selenium/webdriver/edge/legacy_support.rb +0 -117
- data/lib/selenium/webdriver/firefox/bridge.rb +0 -89
- data/lib/selenium/webdriver/ie/bridge.rb +0 -88
- data/lib/selenium/webdriver/ie/server.rb +0 -133
- data/lib/selenium/webdriver/iphone/bridge.rb +0 -64
- data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -78
- data/lib/selenium/webdriver/phantomjs/service.rb +0 -130
- data/lib/selenium/webdriver/remote/commands.rb +0 -211
- data/lib/selenium/webdriver/remote/w3c_bridge.rb +0 -668
- data/lib/selenium/webdriver/remote/w3c_capabilities.rb +0 -236
- data/lib/selenium/webdriver/remote/w3c_commands.rb +0 -132
- data/lib/selenium/webdriver/safari/resources/client.js +0 -7255
- data/lib/selenium/webdriver/safari/server.rb +0 -187
- data/lib/selenium-client.rb +0 -21
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
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
|
|
@@ -23,7 +23,6 @@ require 'socket'
|
|
|
23
23
|
module Selenium
|
|
24
24
|
module WebDriver
|
|
25
25
|
class SocketPoller
|
|
26
|
-
|
|
27
26
|
def initialize(host, port, timeout = 0, interval = 0.25)
|
|
28
27
|
@host = host
|
|
29
28
|
@port = Integer(port)
|
|
@@ -50,18 +49,21 @@ module Selenium
|
|
|
50
49
|
#
|
|
51
50
|
|
|
52
51
|
def closed?
|
|
53
|
-
with_timeout {
|
|
52
|
+
with_timeout { !listening? }
|
|
54
53
|
end
|
|
55
54
|
|
|
56
55
|
private
|
|
57
56
|
|
|
58
57
|
CONNECT_TIMEOUT = 5
|
|
59
58
|
|
|
60
|
-
NOT_CONNECTED_ERRORS = [Errno::ECONNREFUSED, Errno::ENOTCONN, SocketError]
|
|
61
|
-
|
|
59
|
+
NOT_CONNECTED_ERRORS = [Errno::ECONNREFUSED, Errno::ENOTCONN, SocketError].tap { |arr|
|
|
60
|
+
arr << Errno::EPERM if Platform.cygwin?
|
|
61
|
+
}.freeze
|
|
62
62
|
|
|
63
|
-
CONNECTED_ERRORS = [Errno::EISCONN]
|
|
64
|
-
|
|
63
|
+
CONNECTED_ERRORS = [Errno::EISCONN].tap { |arr|
|
|
64
|
+
arr << Errno::EINVAL if Platform.windows?
|
|
65
|
+
arr << Errno::EALREADY if Platform.wsl?
|
|
66
|
+
}.freeze
|
|
65
67
|
|
|
66
68
|
if Platform.jruby?
|
|
67
69
|
# we use a plain TCPSocket here since JRuby has issues select()ing on a connecting socket
|
|
@@ -81,11 +83,8 @@ module Selenium
|
|
|
81
83
|
begin
|
|
82
84
|
sock.connect_nonblock sockaddr
|
|
83
85
|
rescue Errno::EINPROGRESS
|
|
84
|
-
if
|
|
85
|
-
|
|
86
|
-
else
|
|
87
|
-
raise Errno::ECONNREFUSED
|
|
88
|
-
end
|
|
86
|
+
retry if socket_writable?(sock) && conn_completed?(sock)
|
|
87
|
+
raise Errno::ECONNREFUSED
|
|
89
88
|
rescue *CONNECTED_ERRORS
|
|
90
89
|
# yay!
|
|
91
90
|
end
|
|
@@ -93,32 +92,35 @@ module Selenium
|
|
|
93
92
|
sock.close
|
|
94
93
|
true
|
|
95
94
|
rescue *NOT_CONNECTED_ERRORS
|
|
96
|
-
sock
|
|
97
|
-
|
|
95
|
+
sock&.close
|
|
96
|
+
WebDriver.logger.debug("polling for socket on #{[@host, @port].inspect}")
|
|
98
97
|
false
|
|
99
98
|
end
|
|
100
99
|
end
|
|
101
100
|
|
|
102
|
-
def
|
|
103
|
-
|
|
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
|
|
104
111
|
|
|
105
|
-
|
|
112
|
+
until current_time > max_time
|
|
106
113
|
return true if yield
|
|
107
|
-
wait
|
|
108
|
-
) until time_now > max_time
|
|
109
114
|
|
|
110
|
-
|
|
111
|
-
|
|
115
|
+
sleep @interval
|
|
116
|
+
end
|
|
112
117
|
|
|
113
|
-
|
|
114
|
-
sleep @interval
|
|
118
|
+
false
|
|
115
119
|
end
|
|
116
120
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
Time.now
|
|
121
|
+
def current_time
|
|
122
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
120
123
|
end
|
|
121
|
-
|
|
122
124
|
end # SocketPoller
|
|
123
125
|
end # WebDriver
|
|
124
126
|
end # Selenium
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
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,7 +20,6 @@
|
|
|
20
20
|
module Selenium
|
|
21
21
|
module WebDriver
|
|
22
22
|
class TargetLocator
|
|
23
|
-
|
|
24
23
|
#
|
|
25
24
|
# @api private
|
|
26
25
|
#
|
|
@@ -34,7 +33,7 @@ module Selenium
|
|
|
34
33
|
#
|
|
35
34
|
|
|
36
35
|
def frame(id)
|
|
37
|
-
@bridge.
|
|
36
|
+
@bridge.switch_to_frame id
|
|
38
37
|
end
|
|
39
38
|
|
|
40
39
|
#
|
|
@@ -42,7 +41,7 @@ module Selenium
|
|
|
42
41
|
#
|
|
43
42
|
|
|
44
43
|
def parent_frame
|
|
45
|
-
@bridge.
|
|
44
|
+
@bridge.switch_to_parent_frame
|
|
46
45
|
end
|
|
47
46
|
|
|
48
47
|
#
|
|
@@ -58,27 +57,27 @@ module Selenium
|
|
|
58
57
|
def window(id)
|
|
59
58
|
if block_given?
|
|
60
59
|
original = begin
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
@bridge.window_handle
|
|
61
|
+
rescue Error::NoSuchWindowError
|
|
62
|
+
nil
|
|
63
|
+
end
|
|
65
64
|
|
|
66
|
-
unless @bridge.
|
|
65
|
+
unless @bridge.window_handles.include? id
|
|
67
66
|
raise Error::NoSuchWindowError, "The specified identifier '#{id}' is not found in the window handle list"
|
|
68
67
|
end
|
|
69
68
|
|
|
70
|
-
@bridge.
|
|
69
|
+
@bridge.switch_to_window id
|
|
71
70
|
|
|
72
71
|
begin
|
|
73
72
|
returned = yield
|
|
74
73
|
ensure
|
|
75
|
-
current_handles = @bridge.
|
|
74
|
+
current_handles = @bridge.window_handles
|
|
76
75
|
original = current_handles.first unless current_handles.include? original
|
|
77
|
-
@bridge.
|
|
76
|
+
@bridge.switch_to_window original
|
|
78
77
|
returned
|
|
79
78
|
end
|
|
80
79
|
else
|
|
81
|
-
@bridge.
|
|
80
|
+
@bridge.switch_to_window id
|
|
82
81
|
end
|
|
83
82
|
end
|
|
84
83
|
|
|
@@ -89,7 +88,7 @@ module Selenium
|
|
|
89
88
|
#
|
|
90
89
|
|
|
91
90
|
def active_element
|
|
92
|
-
@bridge.
|
|
91
|
+
@bridge.switch_to_active_element
|
|
93
92
|
end
|
|
94
93
|
|
|
95
94
|
#
|
|
@@ -97,7 +96,7 @@ module Selenium
|
|
|
97
96
|
#
|
|
98
97
|
|
|
99
98
|
def default_content
|
|
100
|
-
@bridge.
|
|
99
|
+
@bridge.switch_to_default_content
|
|
101
100
|
end
|
|
102
101
|
|
|
103
102
|
#
|
|
@@ -107,7 +106,6 @@ module Selenium
|
|
|
107
106
|
def alert
|
|
108
107
|
Alert.new(@bridge)
|
|
109
108
|
end
|
|
110
|
-
|
|
111
109
|
end # TargetLocator
|
|
112
110
|
end # WebDriver
|
|
113
|
-
end
|
|
111
|
+
end # Selenium
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
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,7 +20,6 @@
|
|
|
20
20
|
module Selenium
|
|
21
21
|
module WebDriver
|
|
22
22
|
class Timeouts
|
|
23
|
-
|
|
24
23
|
def initialize(bridge)
|
|
25
24
|
@bridge = bridge
|
|
26
25
|
end
|
|
@@ -30,7 +29,7 @@ module Selenium
|
|
|
30
29
|
#
|
|
31
30
|
|
|
32
31
|
def implicit_wait=(seconds)
|
|
33
|
-
@bridge.
|
|
32
|
+
@bridge.implicit_wait_timeout = Integer(seconds * 1000)
|
|
34
33
|
end
|
|
35
34
|
|
|
36
35
|
#
|
|
@@ -40,7 +39,7 @@ module Selenium
|
|
|
40
39
|
#
|
|
41
40
|
|
|
42
41
|
def script_timeout=(seconds)
|
|
43
|
-
@bridge.
|
|
42
|
+
@bridge.script_timeout = Integer(seconds * 1000)
|
|
44
43
|
end
|
|
45
44
|
|
|
46
45
|
#
|
|
@@ -49,9 +48,8 @@ module Selenium
|
|
|
49
48
|
#
|
|
50
49
|
|
|
51
50
|
def page_load=(seconds)
|
|
52
|
-
@bridge.
|
|
51
|
+
@bridge.timeout 'page load', Integer(seconds * 1000)
|
|
53
52
|
end
|
|
54
|
-
|
|
55
53
|
end # Timeouts
|
|
56
54
|
end # WebDriver
|
|
57
|
-
end # Selenium
|
|
55
|
+
end # Selenium
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
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,29 +20,25 @@
|
|
|
20
20
|
module Selenium
|
|
21
21
|
module WebDriver
|
|
22
22
|
class TouchActionBuilder < ActionBuilder
|
|
23
|
-
|
|
24
23
|
#
|
|
25
24
|
# @api private
|
|
26
25
|
#
|
|
27
26
|
|
|
28
27
|
def initialize(mouse, keyboard, touch_screen)
|
|
28
|
+
WebDriver.logger.deprecate(self.class.name)
|
|
29
29
|
super(mouse, keyboard)
|
|
30
30
|
@devices[:touch_screen] = touch_screen
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
def scroll(*args)
|
|
34
|
-
unless [2,3].include? args.size
|
|
35
|
-
raise ArgumentError, "wrong number of arguments, expected 2..3, got #{args.size}"
|
|
36
|
-
end
|
|
34
|
+
raise ArgumentError, "wrong number of arguments, expected 2..3, got #{args.size}" unless [2, 3].include? args.size
|
|
37
35
|
|
|
38
36
|
@actions << [:touch_screen, :scroll, args]
|
|
39
37
|
self
|
|
40
38
|
end
|
|
41
39
|
|
|
42
40
|
def flick(*args)
|
|
43
|
-
unless [2,4].include? args.size
|
|
44
|
-
raise ArgumentError, "wrong number of arguments, expected 2 or 4, got #{args.size}"
|
|
45
|
-
end
|
|
41
|
+
raise ArgumentError, "wrong number of arguments, expected 2 or 4, got #{args.size}" unless [2, 4].include? args.size
|
|
46
42
|
|
|
47
43
|
@actions << [:touch_screen, :flick, args]
|
|
48
44
|
self
|
|
@@ -77,7 +73,6 @@ module Selenium
|
|
|
77
73
|
@actions << [:touch_screen, :move, [x, y]]
|
|
78
74
|
self
|
|
79
75
|
end
|
|
80
|
-
|
|
81
76
|
end # TouchActionBuilder
|
|
82
77
|
end # WebDriver
|
|
83
78
|
end # Selenium
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
#
|
|
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,8 +20,7 @@
|
|
|
20
20
|
module Selenium
|
|
21
21
|
module WebDriver
|
|
22
22
|
class TouchScreen
|
|
23
|
-
FLICK_SPEED = {
|
|
24
|
-
|
|
23
|
+
FLICK_SPEED = {normal: 0, fast: 1}.freeze
|
|
25
24
|
|
|
26
25
|
#
|
|
27
26
|
# @api private
|
|
@@ -33,43 +32,43 @@ module Selenium
|
|
|
33
32
|
|
|
34
33
|
def single_tap(element)
|
|
35
34
|
assert_element element
|
|
36
|
-
@bridge.
|
|
35
|
+
@bridge.touch_single_tap element.ref
|
|
37
36
|
end
|
|
38
37
|
|
|
39
38
|
def double_tap(element)
|
|
40
39
|
assert_element element
|
|
41
|
-
@bridge.
|
|
40
|
+
@bridge.touch_double_tap element.ref
|
|
42
41
|
end
|
|
43
42
|
|
|
44
43
|
def long_press(element)
|
|
45
44
|
assert_element element
|
|
46
|
-
@bridge.
|
|
45
|
+
@bridge.touch_long_press element.ref
|
|
47
46
|
end
|
|
48
47
|
|
|
49
48
|
def down(x, y = nil)
|
|
50
49
|
x, y = coords_from x, y
|
|
51
|
-
@bridge.
|
|
50
|
+
@bridge.touch_down x, y
|
|
52
51
|
end
|
|
53
52
|
|
|
54
53
|
def up(x, y = nil)
|
|
55
54
|
x, y = coords_from x, y
|
|
56
|
-
@bridge.
|
|
55
|
+
@bridge.touch_up x, y
|
|
57
56
|
end
|
|
58
57
|
|
|
59
58
|
def move(x, y = nil)
|
|
60
59
|
x, y = coords_from x, y
|
|
61
|
-
@bridge.
|
|
60
|
+
@bridge.touch_move x, y
|
|
62
61
|
end
|
|
63
62
|
|
|
64
63
|
def scroll(*args)
|
|
65
64
|
case args.size
|
|
66
65
|
when 2
|
|
67
66
|
x_offset, y_offset = args
|
|
68
|
-
@bridge.
|
|
67
|
+
@bridge.touch_scroll nil, Integer(x_offset), Integer(y_offset)
|
|
69
68
|
when 3
|
|
70
69
|
element, x_offset, y_offset = args
|
|
71
70
|
assert_element element
|
|
72
|
-
@bridge.
|
|
71
|
+
@bridge.touch_scroll element.ref, Integer(x_offset), Integer(y_offset)
|
|
73
72
|
else
|
|
74
73
|
raise ArgumentError, "wrong number of arguments, expected 2..3, got #{args.size}"
|
|
75
74
|
end
|
|
@@ -79,22 +78,22 @@ module Selenium
|
|
|
79
78
|
case args.size
|
|
80
79
|
when 2
|
|
81
80
|
x_speed, y_speed = args
|
|
82
|
-
@bridge.
|
|
81
|
+
@bridge.touch_flick Integer(x_speed), Integer(y_speed)
|
|
83
82
|
when 4
|
|
84
83
|
element, xoffset, yoffset, speed = args
|
|
85
84
|
|
|
86
85
|
assert_element element
|
|
87
|
-
flick_speed = FLICK_SPEED[speed.to_sym]
|
|
88
86
|
|
|
89
|
-
|
|
90
|
-
|
|
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]
|
|
91
91
|
end
|
|
92
92
|
|
|
93
|
-
@bridge.
|
|
93
|
+
@bridge.touch_element_flick element.ref, Integer(xoffset), Integer(yoffset), Integer(speed)
|
|
94
94
|
else
|
|
95
95
|
raise ArgumentError, "wrong number of arguments, expected 2 or 4, got #{args.size}"
|
|
96
96
|
end
|
|
97
|
-
|
|
98
97
|
end
|
|
99
98
|
|
|
100
99
|
private
|
|
@@ -107,18 +106,18 @@ module Selenium
|
|
|
107
106
|
raise ArgumentError, "expected #{point.inspect} to respond to :x and :y"
|
|
108
107
|
end
|
|
109
108
|
|
|
110
|
-
x
|
|
109
|
+
x = point.x
|
|
110
|
+
y = point.y
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
[Integer(x), Integer(y)]
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
def assert_element(element)
|
|
117
|
-
|
|
118
|
-
raise TypeError, "expected #{Element}, got #{element.inspect}:#{element.class}"
|
|
119
|
-
end
|
|
120
|
-
end
|
|
117
|
+
return if element.is_a? Element
|
|
121
118
|
|
|
119
|
+
raise TypeError, "expected #{Element}, got #{element.inspect}:#{element.class}"
|
|
120
|
+
end
|
|
122
121
|
end # TouchScreen
|
|
123
122
|
end # WebDriver
|
|
124
123
|
end # Selenium
|
|
@@ -0,0 +1,212 @@
|
|
|
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
|
+
class W3CActionBuilder
|
|
23
|
+
include KeyActions # Actions specific to key inputs
|
|
24
|
+
include PointerActions # Actions specific to pointer inputs
|
|
25
|
+
attr_reader :devices
|
|
26
|
+
|
|
27
|
+
#
|
|
28
|
+
# Initialize a W3C Action Builder. Differs from previous by requiring a bridge and allowing asynchronous actions.
|
|
29
|
+
# The W3C implementation allows asynchronous actions per device. e.g. A key can be pressed at the same time that
|
|
30
|
+
# the mouse is moving. Keep in mind that pauses must be added for other devices in order to line up the actions
|
|
31
|
+
# correctly when using asynchronous.
|
|
32
|
+
#
|
|
33
|
+
# @param [Selenium::WebDriver::Remote::W3CBridge] bridge the bridge for the current driver instance
|
|
34
|
+
# @param [Selenium::WebDriver::Interactions::PointerInput] mouse PointerInput for the mouse.
|
|
35
|
+
# @param [Selenium::WebDriver::Interactions::KeyInput] keyboard KeyInput for the keyboard.
|
|
36
|
+
# @param [Boolean] async Whether to perform the actions asynchronously per device. Defaults to false for
|
|
37
|
+
# backwards compatibility.
|
|
38
|
+
# @return [W3CActionBuilder] A self reference.
|
|
39
|
+
#
|
|
40
|
+
|
|
41
|
+
def initialize(bridge, mouse, keyboard, async = false)
|
|
42
|
+
# For backwards compatibility, automatically include mouse & keyboard
|
|
43
|
+
@bridge = bridge
|
|
44
|
+
@devices = [mouse, keyboard]
|
|
45
|
+
@async = async
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
#
|
|
49
|
+
# Adds a PointerInput device of the given kind
|
|
50
|
+
#
|
|
51
|
+
# @example Add a touch pointer input device
|
|
52
|
+
#
|
|
53
|
+
# builder = device.action
|
|
54
|
+
# builder.add_pointer_input('touch', :touch)
|
|
55
|
+
#
|
|
56
|
+
# @param [String] name name for the device
|
|
57
|
+
# @param [Symbol] kind kind of pointer device to create
|
|
58
|
+
# @return [Interactions::PointerInput] The pointer input added
|
|
59
|
+
#
|
|
60
|
+
#
|
|
61
|
+
|
|
62
|
+
def add_pointer_input(kind, name)
|
|
63
|
+
new_input = Interactions.pointer(kind, name: name)
|
|
64
|
+
add_input(new_input)
|
|
65
|
+
new_input
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
#
|
|
69
|
+
# Adds a KeyInput device
|
|
70
|
+
#
|
|
71
|
+
# @example Add a key input device
|
|
72
|
+
#
|
|
73
|
+
# builder = device.action
|
|
74
|
+
# builder.add_key_input('keyboard2')
|
|
75
|
+
#
|
|
76
|
+
# @param [String] name name for the device
|
|
77
|
+
# @return [Interactions::KeyInput] The key input added
|
|
78
|
+
#
|
|
79
|
+
|
|
80
|
+
def add_key_input(name)
|
|
81
|
+
new_input = Interactions.key(name)
|
|
82
|
+
add_input(new_input)
|
|
83
|
+
new_input
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
#
|
|
87
|
+
# Retrieves the input device for the given name
|
|
88
|
+
#
|
|
89
|
+
# @param [String] name name of the input device
|
|
90
|
+
# @return [Selenium::WebDriver::Interactions::InputDevice] input device with given name
|
|
91
|
+
#
|
|
92
|
+
|
|
93
|
+
def get_device(name)
|
|
94
|
+
@devices.find { |device| device.name == name.to_s }
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
#
|
|
98
|
+
# Retrieves the current PointerInput devices
|
|
99
|
+
#
|
|
100
|
+
# @return [Array] array of current PointerInput devices
|
|
101
|
+
#
|
|
102
|
+
|
|
103
|
+
def pointer_inputs
|
|
104
|
+
@devices.select { |device| device.type == Interactions::POINTER }
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
#
|
|
108
|
+
# Retrieves the current KeyInput device
|
|
109
|
+
#
|
|
110
|
+
# @return [Selenium::WebDriver::Interactions::InputDevice] current KeyInput device
|
|
111
|
+
#
|
|
112
|
+
|
|
113
|
+
def key_inputs
|
|
114
|
+
@devices.select { |device| device.type == Interactions::KEY }
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
#
|
|
118
|
+
# Creates a pause for the given device of the given duration. If no duration is given, the pause will only wait
|
|
119
|
+
# for all actions to complete in that tick.
|
|
120
|
+
#
|
|
121
|
+
# @example Send keys to an element
|
|
122
|
+
#
|
|
123
|
+
# action_builder = driver.action
|
|
124
|
+
# keyboard = action_builder.key_input
|
|
125
|
+
# el = driver.find_element(id: "some_id")
|
|
126
|
+
# driver.action.click(el).pause(keyboard).pause(keyboard).pause(keyboard).send_keys('keys').perform
|
|
127
|
+
#
|
|
128
|
+
# @param [InputDevice] device Input device to pause
|
|
129
|
+
# @param [Float] duration Duration to pause
|
|
130
|
+
# @return [W3CActionBuilder] A self reference.
|
|
131
|
+
#
|
|
132
|
+
|
|
133
|
+
def pause(device, duration = nil)
|
|
134
|
+
device.create_pause(duration)
|
|
135
|
+
self
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
#
|
|
139
|
+
# Creates multiple pauses for the given device of the given duration.
|
|
140
|
+
#
|
|
141
|
+
# @example Send keys to an element
|
|
142
|
+
#
|
|
143
|
+
# action_builder = driver.action
|
|
144
|
+
# keyboard = action_builder.key_input
|
|
145
|
+
# el = driver.find_element(id: "some_id")
|
|
146
|
+
# driver.action.click(el).pauses(keyboard, 3).send_keys('keys').perform
|
|
147
|
+
#
|
|
148
|
+
# @param [InputDevice] device Input device to pause
|
|
149
|
+
# @param [Integer] number of pauses to add for the device
|
|
150
|
+
# @param [Float] duration Duration to pause
|
|
151
|
+
# @return [W3CActionBuilder] A self reference.
|
|
152
|
+
#
|
|
153
|
+
|
|
154
|
+
def pauses(device, number, duration = nil)
|
|
155
|
+
number.times { device.create_pause(duration) }
|
|
156
|
+
self
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
#
|
|
160
|
+
# Executes the actions added to the builder.
|
|
161
|
+
#
|
|
162
|
+
|
|
163
|
+
def perform
|
|
164
|
+
@bridge.send_actions @devices.map(&:encode).compact
|
|
165
|
+
clear_all_actions
|
|
166
|
+
nil
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
#
|
|
170
|
+
# Clears all actions from the builder.
|
|
171
|
+
#
|
|
172
|
+
|
|
173
|
+
def clear_all_actions
|
|
174
|
+
@devices.each(&:clear_actions)
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
#
|
|
178
|
+
# Releases all action states from the browser.
|
|
179
|
+
#
|
|
180
|
+
|
|
181
|
+
def release_actions
|
|
182
|
+
@bridge.release_actions
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
private
|
|
186
|
+
|
|
187
|
+
#
|
|
188
|
+
# Adds pauses for all devices but the given devices
|
|
189
|
+
#
|
|
190
|
+
# @param [Array[InputDevice]] action_devices Array of Input Devices performing an action in this tick.
|
|
191
|
+
#
|
|
192
|
+
|
|
193
|
+
def tick(*action_devices)
|
|
194
|
+
return if @async
|
|
195
|
+
|
|
196
|
+
@devices.each { |device| device.create_pause unless action_devices.include? device }
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
#
|
|
200
|
+
# Adds an InputDevice
|
|
201
|
+
#
|
|
202
|
+
|
|
203
|
+
def add_input(device)
|
|
204
|
+
unless @async
|
|
205
|
+
max_device = @devices.max { |a, b| a.actions.length <=> b.actions.length }
|
|
206
|
+
pauses(device, max_device.actions.length)
|
|
207
|
+
end
|
|
208
|
+
@devices << device
|
|
209
|
+
end
|
|
210
|
+
end # W3CActionBuilder
|
|
211
|
+
end # WebDriver
|
|
212
|
+
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
|
+
class W3CManager < Manager
|
|
23
|
+
|
|
24
|
+
#
|
|
25
|
+
# Get the cookie with the given name
|
|
26
|
+
#
|
|
27
|
+
# @param [String] name the name of the cookie
|
|
28
|
+
# @return [Hash, nil] the cookie, or nil if it wasn't found.
|
|
29
|
+
#
|
|
30
|
+
|
|
31
|
+
def cookie_named(name)
|
|
32
|
+
convert_cookie(@bridge.cookie(name))
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
#
|
|
36
|
+
# Delete all cookies
|
|
37
|
+
#
|
|
38
|
+
|
|
39
|
+
def delete_all_cookies
|
|
40
|
+
@bridge.delete_all_cookies
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end # WC3Options
|
|
44
|
+
end # WebDriver
|
|
45
|
+
end # Selenium
|