selenium-webdriver 2.53.3 → 3.142.7
Sign up to get free protection for your applications and to get access to all the features.
- 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
|
@@ -20,107 +20,40 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Chrome
|
23
|
-
|
24
23
|
#
|
25
24
|
# @api private
|
26
25
|
#
|
27
26
|
|
28
|
-
class Service
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
path = Platform.find_binary "chromedriver"
|
38
|
-
path or raise Error::WebDriverError, MISSING_TEXT
|
39
|
-
Platform.assert_executable path
|
40
|
-
|
41
|
-
path
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
def self.executable_path=(path)
|
46
|
-
Platform.assert_executable path
|
47
|
-
@executable_path = path
|
48
|
-
end
|
49
|
-
|
50
|
-
def self.default_service(*extra_args)
|
51
|
-
new executable_path, DEFAULT_PORT, *extra_args
|
52
|
-
end
|
53
|
-
|
54
|
-
def initialize(executable_path, port, *extra_args)
|
55
|
-
@executable_path = executable_path
|
56
|
-
@host = Platform.localhost
|
57
|
-
@port = Integer(port)
|
58
|
-
|
59
|
-
raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1
|
60
|
-
|
61
|
-
@extra_args = extra_args
|
62
|
-
end
|
63
|
-
|
64
|
-
def start
|
65
|
-
Platform.exit_hook { stop } # make sure we don't leave the server running
|
66
|
-
|
67
|
-
socket_lock.locked do
|
68
|
-
find_free_port
|
69
|
-
start_process
|
70
|
-
connect_until_stable
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def stop
|
75
|
-
return if @process.nil? || @process.exited?
|
76
|
-
|
77
|
-
Net::HTTP.start(@host, @port) do |http|
|
78
|
-
http.open_timeout = STOP_TIMEOUT / 2
|
79
|
-
http.read_timeout = STOP_TIMEOUT / 2
|
80
|
-
|
81
|
-
http.get("/shutdown")
|
82
|
-
end
|
83
|
-
ensure
|
84
|
-
stop_process
|
85
|
-
end
|
27
|
+
class Service < WebDriver::Service
|
28
|
+
@default_port = 9515
|
29
|
+
@executable = 'chromedriver'
|
30
|
+
@missing_text = <<~ERROR
|
31
|
+
Unable to find chromedriver. Please download the server from
|
32
|
+
https://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH.
|
33
|
+
More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver.
|
34
|
+
ERROR
|
35
|
+
@shutdown_supported = true
|
86
36
|
|
87
|
-
def
|
88
|
-
|
37
|
+
def self.driver_path=(path)
|
38
|
+
Platform.assert_executable path if path.is_a?(String)
|
39
|
+
@driver_path = path
|
89
40
|
end
|
90
41
|
|
91
42
|
private
|
92
43
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
44
|
+
# Note: This processing is deprecated
|
45
|
+
def extract_service_args(driver_opts)
|
46
|
+
driver_args = super
|
47
|
+
driver_opts = driver_opts.dup
|
48
|
+
driver_args << "--log-path=#{driver_opts.delete(:log_path)}" if driver_opts.key?(:log_path)
|
49
|
+
driver_args << "--url-base=#{driver_opts.delete(:url_base)}" if driver_opts.key?(:url_base)
|
50
|
+
driver_args << "--port-server=#{driver_opts.delete(:port_server)}" if driver_opts.key?(:port_server)
|
51
|
+
driver_args << "--whitelisted-ips=#{driver_opts.delete(:whitelisted_ips)}" if driver_opts.key?(:whitelisted_ips)
|
52
|
+
driver_args << "--verbose" if driver_opts.key?(:verbose)
|
53
|
+
driver_args << "--silent" if driver_opts.key?(:silent)
|
54
|
+
driver_args
|
103
55
|
end
|
104
|
-
|
105
|
-
def stop_process
|
106
|
-
@process.poll_for_exit STOP_TIMEOUT
|
107
|
-
rescue ChildProcess::TimeoutError
|
108
|
-
@process.stop STOP_TIMEOUT
|
109
|
-
end
|
110
|
-
|
111
|
-
def connect_until_stable
|
112
|
-
socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
|
113
|
-
|
114
|
-
unless socket_poller.connected?
|
115
|
-
raise Error::WebDriverError, "unable to connect to chromedriver #{@host}:#{@port}"
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
def socket_lock
|
120
|
-
@socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT)
|
121
|
-
end
|
122
|
-
|
123
56
|
end # Service
|
124
57
|
end # Chrome
|
125
58
|
end # WebDriver
|
126
|
-
end #
|
59
|
+
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
|
@@ -19,16 +19,24 @@
|
|
19
19
|
|
20
20
|
require 'net/http'
|
21
21
|
|
22
|
-
require 'selenium/webdriver/chrome/service'
|
23
22
|
require 'selenium/webdriver/chrome/bridge'
|
23
|
+
require 'selenium/webdriver/chrome/driver'
|
24
24
|
require 'selenium/webdriver/chrome/profile'
|
25
|
+
require 'selenium/webdriver/chrome/options'
|
25
26
|
|
26
27
|
module Selenium
|
27
28
|
module WebDriver
|
28
|
-
|
29
29
|
module Chrome
|
30
30
|
def self.driver_path=(path)
|
31
|
-
|
31
|
+
WebDriver.logger.deprecate 'Selenium::WebDriver::Chrome#driver_path=',
|
32
|
+
'Selenium::WebDriver::Chrome::Service#driver_path='
|
33
|
+
Selenium::WebDriver::Chrome::Service.driver_path = path
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.driver_path
|
37
|
+
WebDriver.logger.deprecate 'Selenium::WebDriver::Chrome#driver_path',
|
38
|
+
'Selenium::WebDriver::Chrome::Service#driver_path'
|
39
|
+
Selenium::WebDriver::Chrome::Service.driver_path
|
32
40
|
end
|
33
41
|
|
34
42
|
def self.path=(path)
|
@@ -39,7 +47,8 @@ module Selenium
|
|
39
47
|
def self.path
|
40
48
|
@path ||= nil
|
41
49
|
end
|
42
|
-
|
43
50
|
end # Chrome
|
44
51
|
end # WebDriver
|
45
52
|
end # Selenium
|
53
|
+
|
54
|
+
require 'selenium/webdriver/chrome/service'
|
@@ -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
|
@@ -19,14 +19,11 @@
|
|
19
19
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
|
-
|
23
22
|
#
|
24
23
|
# The ActionBuilder provides the user a way to set up and perform
|
25
24
|
# complex user interactions.
|
26
25
|
#
|
27
|
-
# This class should not be instantiated directly, but is created by
|
28
|
-
# Selenium::WebDriver::DriverExtensions::HasInputDevices#action, which
|
29
|
-
# is available on Driver instances that support the user interaction API.
|
26
|
+
# This class should not be instantiated directly, but is created by Driver#action
|
30
27
|
#
|
31
28
|
# @example
|
32
29
|
#
|
@@ -39,18 +36,17 @@ module Selenium
|
|
39
36
|
#
|
40
37
|
|
41
38
|
class ActionBuilder
|
42
|
-
|
43
39
|
#
|
44
40
|
# @api private
|
45
41
|
#
|
46
42
|
|
47
43
|
def initialize(mouse, keyboard)
|
48
|
-
@devices
|
49
|
-
:
|
50
|
-
:
|
44
|
+
@devices = {
|
45
|
+
mouse: mouse,
|
46
|
+
keyboard: keyboard
|
51
47
|
}
|
52
48
|
|
53
|
-
@actions
|
49
|
+
@actions = []
|
54
50
|
end
|
55
51
|
|
56
52
|
#
|
@@ -70,19 +66,19 @@ module Selenium
|
|
70
66
|
#
|
71
67
|
# @example Press a key on an element
|
72
68
|
#
|
73
|
-
# el = driver.find_element(:
|
69
|
+
# el = driver.find_element(id: "some_id")
|
74
70
|
# driver.action.key_down(el, :shift).perform
|
75
71
|
#
|
76
|
-
# @
|
77
|
-
#
|
72
|
+
# @overload key_down(key)
|
73
|
+
# @param [:shift, :alt, :control, :command, :meta] key The modifier key to press
|
74
|
+
# @overload key_down(element, key)
|
75
|
+
# @param [Element] element An optional element to move to first
|
76
|
+
# @param [:shift, :alt, :control, :command, :meta] key The modifier key to press
|
78
77
|
# @raise [ArgumentError] if the given key is not a modifier
|
79
|
-
# @return [ActionBuilder] A self reference
|
80
|
-
#
|
78
|
+
# @return [ActionBuilder] A self reference
|
81
79
|
|
82
80
|
def key_down(*args)
|
83
|
-
if args.first.
|
84
|
-
@actions << [:mouse, :click, [args.shift]]
|
85
|
-
end
|
81
|
+
@actions << [:mouse, :click, [args.shift]] if args.first.is_a? Element
|
86
82
|
|
87
83
|
@actions << [:keyboard, :press, args]
|
88
84
|
self
|
@@ -98,19 +94,20 @@ module Selenium
|
|
98
94
|
#
|
99
95
|
# @example Release a key from an element
|
100
96
|
#
|
101
|
-
# el = driver.find_element(:
|
97
|
+
# el = driver.find_element(id: "some_id")
|
102
98
|
# driver.action.key_up(el, :alt).perform
|
103
99
|
#
|
104
|
-
# @
|
105
|
-
#
|
106
|
-
# @
|
107
|
-
#
|
100
|
+
# @overload key_up(key)
|
101
|
+
# @param [:shift, :alt, :control, :command, :meta] key The modifier key to release
|
102
|
+
# @overload key_up(element, key)
|
103
|
+
# @param [Element] element An optional element to move to first
|
104
|
+
# @param [:shift, :alt, :control, :command, :meta] key The modifier key to release
|
105
|
+
# @raise [ArgumentError] if the given key is not a modifier
|
106
|
+
# @return [ActionBuilder] A self reference
|
108
107
|
#
|
109
108
|
|
110
109
|
def key_up(*args)
|
111
|
-
if args.first.
|
112
|
-
@actions << [:mouse, :click, [args.shift]]
|
113
|
-
end
|
110
|
+
@actions << [:mouse, :click, [args.shift]] if args.first.is_a? Element
|
114
111
|
|
115
112
|
@actions << [:keyboard, :release, args]
|
116
113
|
self
|
@@ -125,22 +122,23 @@ module Selenium
|
|
125
122
|
#
|
126
123
|
# @example Send the text "help" to an element
|
127
124
|
#
|
128
|
-
# el = driver.find_element(:
|
125
|
+
# el = driver.find_element(id: "some_id")
|
129
126
|
# driver.action.send_keys(el, "help").perform
|
130
127
|
#
|
131
128
|
# @example Send the text "help" to the currently focused element
|
132
129
|
#
|
133
130
|
# driver.action.send_keys("help").perform
|
134
131
|
#
|
135
|
-
# @
|
136
|
-
#
|
137
|
-
# @
|
132
|
+
# @overload send_keys(keys)
|
133
|
+
# @param [Array, Symbol, String] keys The key(s) to press and release
|
134
|
+
# @overload send_keys(element, keys)
|
135
|
+
# @param [Element] element An optional element to move to first
|
136
|
+
# @param [Array, Symbol, String] keys The key(s) to press and release
|
137
|
+
# @return [ActionBuilder] A self reference
|
138
138
|
#
|
139
139
|
|
140
140
|
def send_keys(*args)
|
141
|
-
if args.first.
|
142
|
-
@actions << [:mouse, :click, [args.shift]]
|
143
|
-
end
|
141
|
+
@actions << [:mouse, :click, [args.shift]] if args.first.is_a? Element
|
144
142
|
|
145
143
|
@actions << [:keyboard, :send_keys, args]
|
146
144
|
self
|
@@ -154,10 +152,10 @@ module Selenium
|
|
154
152
|
#
|
155
153
|
# @example Clicking and holding on some element
|
156
154
|
#
|
157
|
-
# el = driver.find_element(:
|
155
|
+
# el = driver.find_element(id: "some_id")
|
158
156
|
# driver.action.click_and_hold(el).perform
|
159
157
|
#
|
160
|
-
# @param [
|
158
|
+
# @param [Element] element the element to move to and click.
|
161
159
|
# @return [ActionBuilder] A self reference.
|
162
160
|
#
|
163
161
|
|
@@ -171,7 +169,7 @@ module Selenium
|
|
171
169
|
#
|
172
170
|
# @example Releasing an element after clicking and holding it
|
173
171
|
#
|
174
|
-
# el = driver.find_element(:
|
172
|
+
# el = driver.find_element(id: "some_id")
|
175
173
|
# driver.action.click_and_hold(el).release.perform
|
176
174
|
#
|
177
175
|
# @return [ActionBuilder] A self reference.
|
@@ -191,7 +189,7 @@ module Selenium
|
|
191
189
|
#
|
192
190
|
# @example Clicking on an element
|
193
191
|
#
|
194
|
-
# el = driver.find_element(:
|
192
|
+
# el = driver.find_element(id: "some_id")
|
195
193
|
# driver.action.click(el).perform
|
196
194
|
#
|
197
195
|
# @example Clicking at the current mouse position
|
@@ -214,7 +212,7 @@ module Selenium
|
|
214
212
|
#
|
215
213
|
# @example Double click an element
|
216
214
|
#
|
217
|
-
# el = driver.find_element(:
|
215
|
+
# el = driver.find_element(id: "some_id")
|
218
216
|
# driver.action.double_click(el).perform
|
219
217
|
#
|
220
218
|
# @param [Selenium::WebDriver::Element] element An optional element to move to.
|
@@ -235,12 +233,12 @@ module Selenium
|
|
235
233
|
#
|
236
234
|
# @example Scroll element into view and move the mouse to it
|
237
235
|
#
|
238
|
-
# el = driver.find_element(:
|
236
|
+
# el = driver.find_element(id: "some_id")
|
239
237
|
# driver.action.move_to(el).perform
|
240
238
|
#
|
241
239
|
# @example
|
242
240
|
#
|
243
|
-
# el = driver.find_element(:
|
241
|
+
# el = driver.find_element(id: "some_id")
|
244
242
|
# driver.action.move_to(el, 100, 100).perform
|
245
243
|
#
|
246
244
|
# @param [Selenium::WebDriver::Element] element to move to.
|
@@ -252,11 +250,11 @@ module Selenium
|
|
252
250
|
#
|
253
251
|
|
254
252
|
def move_to(element, right_by = nil, down_by = nil)
|
255
|
-
if right_by && down_by
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
253
|
+
@actions << if right_by && down_by
|
254
|
+
[:mouse, :move_to, [element, Integer(right_by), Integer(down_by)]]
|
255
|
+
else
|
256
|
+
[:mouse, :move_to, [element]]
|
257
|
+
end
|
260
258
|
|
261
259
|
self
|
262
260
|
end
|
@@ -281,7 +279,7 @@ module Selenium
|
|
281
279
|
#
|
282
280
|
|
283
281
|
def move_by(right_by, down_by)
|
284
|
-
@actions << [:mouse, :move_by, [right_by, down_by]]
|
282
|
+
@actions << [:mouse, :move_by, [Integer(right_by), Integer(down_by)]]
|
285
283
|
self
|
286
284
|
end
|
287
285
|
|
@@ -291,7 +289,7 @@ module Selenium
|
|
291
289
|
#
|
292
290
|
# @example Context-click at middle of given element
|
293
291
|
#
|
294
|
-
# el = driver.find_element(:
|
292
|
+
# el = driver.find_element(id: "some_id")
|
295
293
|
# driver.action.context_click(el).perform
|
296
294
|
#
|
297
295
|
# @param [Selenium::WebDriver::Element] element An element to context click.
|
@@ -310,8 +308,8 @@ module Selenium
|
|
310
308
|
#
|
311
309
|
# @example Drag and drop one element onto another
|
312
310
|
#
|
313
|
-
# el1 = driver.find_element(:
|
314
|
-
# el2 = driver.find_element(:
|
311
|
+
# el1 = driver.find_element(id: "some_id1")
|
312
|
+
# el2 = driver.find_element(id: "some_id2")
|
315
313
|
# driver.action.drag_and_drop(el1, el2).perform
|
316
314
|
#
|
317
315
|
# @param [Selenium::WebDriver::Element] source element to emulate button down at.
|
@@ -323,7 +321,7 @@ module Selenium
|
|
323
321
|
def drag_and_drop(source, target)
|
324
322
|
click_and_hold source
|
325
323
|
move_to target
|
326
|
-
release
|
324
|
+
release
|
327
325
|
|
328
326
|
self
|
329
327
|
end
|
@@ -334,14 +332,12 @@ module Selenium
|
|
334
332
|
#
|
335
333
|
# @example Drag and drop an element by offset
|
336
334
|
#
|
337
|
-
# el = driver.find_element(:
|
335
|
+
# el = driver.find_element(id: "some_id1")
|
338
336
|
# driver.action.drag_and_drop_by(el, 100, 100).perform
|
339
337
|
#
|
340
338
|
# @param [Selenium::WebDriver::Element] source Element to emulate button down at.
|
341
339
|
# @param [Integer] right_by horizontal move offset.
|
342
340
|
# @param [Integer] down_by vertical move offset.
|
343
|
-
# @param [Selenium::WebDriver::Element] target Element to move to and release the
|
344
|
-
# mouse at.
|
345
341
|
# @return [ActionBuilder] A self reference.
|
346
342
|
#
|
347
343
|
|
@@ -353,19 +349,17 @@ module Selenium
|
|
353
349
|
self
|
354
350
|
end
|
355
351
|
|
356
|
-
|
357
352
|
#
|
358
353
|
# Executes the actions added to the builder.
|
359
354
|
#
|
360
355
|
|
361
356
|
def perform
|
362
|
-
@actions.each
|
357
|
+
@actions.each do |receiver, method, args|
|
363
358
|
@devices.fetch(receiver).__send__(method, *args)
|
364
|
-
|
359
|
+
end
|
365
360
|
|
366
361
|
nil
|
367
362
|
end
|
368
|
-
|
369
363
|
end # ActionBuilder
|
370
364
|
end # WebDriver
|
371
365
|
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,36 +20,28 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
class Alert
|
23
|
-
|
24
23
|
def initialize(bridge)
|
25
24
|
@bridge = bridge
|
26
25
|
|
27
26
|
# fail fast if the alert doesn't exist
|
28
|
-
bridge.
|
27
|
+
bridge.alert_text
|
29
28
|
end
|
30
29
|
|
31
30
|
def accept
|
32
|
-
@bridge.
|
31
|
+
@bridge.accept_alert
|
33
32
|
end
|
34
33
|
|
35
34
|
def dismiss
|
36
|
-
@bridge.
|
35
|
+
@bridge.dismiss_alert
|
37
36
|
end
|
38
37
|
|
39
38
|
def send_keys(keys)
|
40
|
-
@bridge.
|
39
|
+
@bridge.alert = keys
|
41
40
|
end
|
42
41
|
|
43
42
|
def text
|
44
|
-
@bridge.
|
43
|
+
@bridge.alert_text
|
45
44
|
end
|
46
|
-
|
47
|
-
def authenticate(username, password)
|
48
|
-
@bridge.setAuthentication username: username, password: password
|
49
|
-
accept
|
50
|
-
end
|
51
|
-
|
52
45
|
end # Alert
|
53
46
|
end # WebDriver
|
54
47
|
end # Selenium
|
55
|
-
|
@@ -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
|
@@ -19,7 +19,6 @@
|
|
19
19
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
|
-
|
23
22
|
#
|
24
23
|
# Shared across bridges
|
25
24
|
#
|
@@ -27,52 +26,50 @@ module Selenium
|
|
27
26
|
#
|
28
27
|
|
29
28
|
module BridgeHelper
|
30
|
-
|
31
29
|
def unwrap_script_result(arg)
|
32
30
|
case arg
|
33
31
|
when Array
|
34
32
|
arg.map { |e| unwrap_script_result(e) }
|
35
33
|
when Hash
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
34
|
+
element_id = element_id_from(arg)
|
35
|
+
return Element.new(self, element_id) if element_id
|
36
|
+
|
37
|
+
arg.each { |k, v| arg[k] = unwrap_script_result(v) }
|
41
38
|
else
|
42
39
|
arg
|
43
40
|
end
|
44
41
|
end
|
45
42
|
|
46
43
|
def element_id_from(id)
|
47
|
-
id['ELEMENT']
|
44
|
+
id['ELEMENT'] || id['element-6066-11e4-a52e-4f735466cecf']
|
48
45
|
end
|
49
46
|
|
50
47
|
def parse_cookie_string(str)
|
51
48
|
result = {
|
52
|
-
'name'
|
53
|
-
'value'
|
54
|
-
'domain'
|
55
|
-
'path'
|
49
|
+
'name' => '',
|
50
|
+
'value' => '',
|
51
|
+
'domain' => '',
|
52
|
+
'path' => '',
|
56
53
|
'expires' => '',
|
57
|
-
'secure'
|
54
|
+
'secure' => false
|
58
55
|
}
|
59
56
|
|
60
|
-
str.split(
|
61
|
-
if attribute.include?
|
62
|
-
key, value = attribute.strip.split(
|
57
|
+
str.split(';').each do |attribute|
|
58
|
+
if attribute.include? '='
|
59
|
+
key, value = attribute.strip.split('=', 2)
|
63
60
|
if result['name'].empty?
|
64
61
|
result['name'] = key
|
65
62
|
result['value'] = value
|
66
63
|
elsif key == 'domain' && value.strip =~ /^\.(.+)/
|
67
|
-
result['domain'] =
|
64
|
+
result['domain'] = Regexp.last_match(1)
|
68
65
|
elsif key && value
|
69
66
|
result[key] = value
|
70
67
|
end
|
71
|
-
elsif attribute ==
|
68
|
+
elsif attribute == 'secure'
|
72
69
|
result['secure'] = true
|
73
70
|
end
|
74
71
|
|
75
|
-
unless [nil,
|
72
|
+
unless [nil, '', '0'].include?(result['expires'])
|
76
73
|
# firefox stores expiry as number of seconds
|
77
74
|
result['expires'] = Time.at(result['expires'].to_i)
|
78
75
|
end
|
@@ -80,7 +77,6 @@ module Selenium
|
|
80
77
|
|
81
78
|
result
|
82
79
|
end
|
83
|
-
|
84
80
|
end # BridgeHelper
|
85
81
|
end # WebDriver
|
86
82
|
end # Selenium
|