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,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
|
|
@@ -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 Wait
|
|
4
|
-
|
|
5
23
|
DEFAULT_TIMEOUT = 5
|
|
6
24
|
DEFAULT_INTERVAL = 0.2
|
|
7
25
|
|
|
@@ -22,19 +40,18 @@ module Selenium
|
|
|
22
40
|
@ignored = Array(opts[:ignore] || Error::NoSuchElementError)
|
|
23
41
|
end
|
|
24
42
|
|
|
25
|
-
|
|
26
43
|
#
|
|
27
44
|
# Wait until the given block returns a true value.
|
|
28
45
|
#
|
|
29
|
-
# @raise [Error::
|
|
46
|
+
# @raise [Error::TimeoutError]
|
|
30
47
|
# @return [Object] the result of the block
|
|
31
48
|
#
|
|
32
49
|
|
|
33
|
-
def until
|
|
34
|
-
end_time =
|
|
50
|
+
def until
|
|
51
|
+
end_time = current_time + @timeout
|
|
35
52
|
last_error = nil
|
|
36
53
|
|
|
37
|
-
until
|
|
54
|
+
until current_time > end_time
|
|
38
55
|
begin
|
|
39
56
|
result = yield
|
|
40
57
|
return result if result
|
|
@@ -45,19 +62,22 @@ module Selenium
|
|
|
45
62
|
sleep @interval
|
|
46
63
|
end
|
|
47
64
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
end
|
|
65
|
+
msg = if @message
|
|
66
|
+
@message.dup
|
|
67
|
+
else
|
|
68
|
+
+"timed out after #{@timeout} seconds"
|
|
69
|
+
end
|
|
54
70
|
|
|
55
71
|
msg << " (#{last_error.message})" if last_error
|
|
56
72
|
|
|
57
|
-
raise Error::
|
|
73
|
+
raise Error::TimeoutError, msg
|
|
58
74
|
end
|
|
59
75
|
|
|
76
|
+
private
|
|
77
|
+
|
|
78
|
+
def current_time
|
|
79
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
|
80
|
+
end
|
|
60
81
|
end # Wait
|
|
61
82
|
end # WebDriver
|
|
62
83
|
end # Selenium
|
|
63
|
-
|
|
@@ -1,12 +1,29 @@
|
|
|
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
|
-
|
|
4
22
|
#
|
|
5
23
|
# @api beta This API may be changed or removed in a future release.
|
|
6
24
|
#
|
|
7
25
|
|
|
8
26
|
class Window
|
|
9
|
-
|
|
10
27
|
#
|
|
11
28
|
# @api private
|
|
12
29
|
#
|
|
@@ -23,11 +40,11 @@ module Selenium
|
|
|
23
40
|
|
|
24
41
|
def size=(dimension)
|
|
25
42
|
unless dimension.respond_to?(:width) && dimension.respond_to?(:height)
|
|
26
|
-
raise ArgumentError, "expected #{dimension.inspect}:#{dimension.class}"
|
|
27
|
-
|
|
43
|
+
raise ArgumentError, "expected #{dimension.inspect}:#{dimension.class}" \
|
|
44
|
+
' to respond to #width and #height'
|
|
28
45
|
end
|
|
29
46
|
|
|
30
|
-
@bridge.
|
|
47
|
+
@bridge.resize_window dimension.width, dimension.height
|
|
31
48
|
end
|
|
32
49
|
|
|
33
50
|
#
|
|
@@ -37,7 +54,7 @@ module Selenium
|
|
|
37
54
|
#
|
|
38
55
|
|
|
39
56
|
def size
|
|
40
|
-
@bridge.
|
|
57
|
+
@bridge.window_size
|
|
41
58
|
end
|
|
42
59
|
|
|
43
60
|
#
|
|
@@ -48,11 +65,11 @@ module Selenium
|
|
|
48
65
|
|
|
49
66
|
def position=(point)
|
|
50
67
|
unless point.respond_to?(:x) && point.respond_to?(:y)
|
|
51
|
-
raise ArgumentError, "expected #{point.inspect}:#{point.class}"
|
|
52
|
-
|
|
68
|
+
raise ArgumentError, "expected #{point.inspect}:#{point.class}" \
|
|
69
|
+
' to respond to #x and #y'
|
|
53
70
|
end
|
|
54
71
|
|
|
55
|
-
@bridge.
|
|
72
|
+
@bridge.reposition_window point.x, point.y
|
|
56
73
|
end
|
|
57
74
|
|
|
58
75
|
#
|
|
@@ -62,7 +79,35 @@ module Selenium
|
|
|
62
79
|
#
|
|
63
80
|
|
|
64
81
|
def position
|
|
65
|
-
@bridge.
|
|
82
|
+
@bridge.window_position
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
#
|
|
86
|
+
# Sets the current window rect to the given point and position.
|
|
87
|
+
#
|
|
88
|
+
# @param [Selenium::WebDriver::Rectangle, #x, #y, #width, #height] rectangle The new rect.
|
|
89
|
+
#
|
|
90
|
+
|
|
91
|
+
def rect=(rectangle)
|
|
92
|
+
unless %w[x y width height].all? { |val| rectangle.respond_to? val }
|
|
93
|
+
raise ArgumentError, "expected #{rectangle.inspect}:#{rectangle.class}" \
|
|
94
|
+
' to respond to #x, #y, #width, and #height'
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
@bridge.set_window_rect(x: rectangle.x,
|
|
98
|
+
y: rectangle.y,
|
|
99
|
+
width: rectangle.width,
|
|
100
|
+
height: rectangle.height)
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
#
|
|
104
|
+
# Get the rect of the current window.
|
|
105
|
+
#
|
|
106
|
+
# @return [Selenium::WebDriver::Rectangle] The rectangle.
|
|
107
|
+
#
|
|
108
|
+
|
|
109
|
+
def rect
|
|
110
|
+
@bridge.window_rect
|
|
66
111
|
end
|
|
67
112
|
|
|
68
113
|
#
|
|
@@ -75,7 +120,7 @@ module Selenium
|
|
|
75
120
|
#
|
|
76
121
|
|
|
77
122
|
def resize_to(width, height)
|
|
78
|
-
@bridge.
|
|
123
|
+
@bridge.resize_window Integer(width), Integer(height)
|
|
79
124
|
end
|
|
80
125
|
|
|
81
126
|
#
|
|
@@ -87,7 +132,7 @@ module Selenium
|
|
|
87
132
|
#
|
|
88
133
|
|
|
89
134
|
def move_to(x, y)
|
|
90
|
-
@bridge.
|
|
135
|
+
@bridge.reposition_window Integer(x), Integer(y)
|
|
91
136
|
end
|
|
92
137
|
|
|
93
138
|
#
|
|
@@ -95,10 +140,24 @@ module Selenium
|
|
|
95
140
|
#
|
|
96
141
|
|
|
97
142
|
def maximize
|
|
98
|
-
@bridge.
|
|
143
|
+
@bridge.maximize_window
|
|
144
|
+
end
|
|
145
|
+
|
|
146
|
+
#
|
|
147
|
+
# Minimize the current window
|
|
148
|
+
#
|
|
149
|
+
|
|
150
|
+
def minimize
|
|
151
|
+
@bridge.minimize_window
|
|
99
152
|
end
|
|
100
153
|
|
|
154
|
+
#
|
|
155
|
+
# Make current window full screen
|
|
156
|
+
#
|
|
101
157
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
end
|
|
158
|
+
def full_screen
|
|
159
|
+
@bridge.full_screen_window
|
|
160
|
+
end
|
|
161
|
+
end # Window
|
|
162
|
+
end # WebDriver
|
|
163
|
+
end # Selenium
|
|
@@ -1,6 +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
|
require 'zip'
|
|
2
21
|
require 'tempfile'
|
|
3
22
|
require 'find'
|
|
23
|
+
require 'base64'
|
|
4
24
|
|
|
5
25
|
module Selenium
|
|
6
26
|
module WebDriver
|
|
@@ -9,13 +29,11 @@ module Selenium
|
|
|
9
29
|
#
|
|
10
30
|
|
|
11
31
|
module Zipper
|
|
12
|
-
|
|
13
|
-
EXTENSIONS = %w[.zip .xpi]
|
|
32
|
+
EXTENSIONS = %w[.zip .xpi].freeze
|
|
14
33
|
|
|
15
34
|
class << self
|
|
16
|
-
|
|
17
35
|
def unzip(path)
|
|
18
|
-
destination = Dir.mktmpdir(
|
|
36
|
+
destination = Dir.mktmpdir('webdriver-unzip')
|
|
19
37
|
FileReaper << destination
|
|
20
38
|
|
|
21
39
|
Zip::File.open(path) do |zip|
|
|
@@ -34,13 +52,11 @@ module Selenium
|
|
|
34
52
|
def zip(path)
|
|
35
53
|
with_tmp_zip do |zip|
|
|
36
54
|
::Find.find(path) do |file|
|
|
37
|
-
unless File.directory?(file)
|
|
38
|
-
add_zip_entry zip, file, file.sub("#{path}/", '')
|
|
39
|
-
end
|
|
55
|
+
add_zip_entry zip, file, file.sub("#{path}/", '') unless File.directory?(file)
|
|
40
56
|
end
|
|
41
57
|
|
|
42
58
|
zip.commit
|
|
43
|
-
File.open(zip.name,
|
|
59
|
+
File.open(zip.name, 'rb') { |io| Base64.strict_encode64 io.read }
|
|
44
60
|
end
|
|
45
61
|
end
|
|
46
62
|
|
|
@@ -49,7 +65,7 @@ module Selenium
|
|
|
49
65
|
add_zip_entry zip, path, File.basename(path)
|
|
50
66
|
|
|
51
67
|
zip.commit
|
|
52
|
-
File.open(zip.name,
|
|
68
|
+
File.open(zip.name, 'rb') { |io| Base64.strict_encode64 io.read }
|
|
53
69
|
end
|
|
54
70
|
end
|
|
55
71
|
|
|
@@ -59,7 +75,7 @@ module Selenium
|
|
|
59
75
|
# can't use Tempfile here since it doesn't support File::BINARY mode on 1.8
|
|
60
76
|
# can't use Dir.mktmpdir(&blk) because of http://jira.codehaus.org/browse/JRUBY-4082
|
|
61
77
|
tmp_dir = Dir.mktmpdir
|
|
62
|
-
zip_path = File.join(tmp_dir,
|
|
78
|
+
zip_path = File.join(tmp_dir, 'webdriver-zip')
|
|
63
79
|
|
|
64
80
|
begin
|
|
65
81
|
Zip::File.open(zip_path, Zip::File::CREATE, &blk)
|
|
@@ -75,7 +91,6 @@ module Selenium
|
|
|
75
91
|
|
|
76
92
|
zip.add entry, file
|
|
77
93
|
end
|
|
78
|
-
|
|
79
94
|
end
|
|
80
95
|
end # Zipper
|
|
81
96
|
end # WebDriver
|
|
@@ -1,11 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
+
|
|
4
20
|
require 'selenium/webdriver/common/error'
|
|
5
21
|
require 'selenium/webdriver/common/platform'
|
|
6
22
|
require 'selenium/webdriver/common/proxy'
|
|
7
23
|
require 'selenium/webdriver/common/log_entry'
|
|
8
24
|
require 'selenium/webdriver/common/file_reaper'
|
|
25
|
+
require 'selenium/webdriver/common/service'
|
|
26
|
+
require 'selenium/webdriver/common/socket_lock'
|
|
9
27
|
require 'selenium/webdriver/common/socket_poller'
|
|
10
28
|
require 'selenium/webdriver/common/port_prober'
|
|
11
29
|
require 'selenium/webdriver/common/zipper'
|
|
@@ -18,27 +36,42 @@ require 'selenium/webdriver/common/target_locator'
|
|
|
18
36
|
require 'selenium/webdriver/common/navigation'
|
|
19
37
|
require 'selenium/webdriver/common/timeouts'
|
|
20
38
|
require 'selenium/webdriver/common/window'
|
|
39
|
+
require 'selenium/webdriver/common/logger'
|
|
21
40
|
require 'selenium/webdriver/common/logs'
|
|
22
|
-
require 'selenium/webdriver/common/
|
|
41
|
+
require 'selenium/webdriver/common/manager'
|
|
42
|
+
require 'selenium/webdriver/common/w3c_manager'
|
|
23
43
|
require 'selenium/webdriver/common/search_context'
|
|
24
44
|
require 'selenium/webdriver/common/action_builder'
|
|
45
|
+
require 'selenium/webdriver/common/interactions/key_actions'
|
|
46
|
+
require 'selenium/webdriver/common/interactions/pointer_actions'
|
|
47
|
+
require 'selenium/webdriver/common/w3c_action_builder'
|
|
25
48
|
require 'selenium/webdriver/common/touch_action_builder'
|
|
26
49
|
require 'selenium/webdriver/common/html5/shared_web_storage'
|
|
27
50
|
require 'selenium/webdriver/common/html5/local_storage'
|
|
28
51
|
require 'selenium/webdriver/common/html5/session_storage'
|
|
29
52
|
require 'selenium/webdriver/common/driver_extensions/takes_screenshot'
|
|
30
53
|
require 'selenium/webdriver/common/driver_extensions/rotatable'
|
|
31
|
-
require 'selenium/webdriver/common/driver_extensions/has_browser_connection'
|
|
32
|
-
require 'selenium/webdriver/common/driver_extensions/has_input_devices'
|
|
33
54
|
require 'selenium/webdriver/common/driver_extensions/has_web_storage'
|
|
55
|
+
require 'selenium/webdriver/common/driver_extensions/downloads_files'
|
|
34
56
|
require 'selenium/webdriver/common/driver_extensions/has_location'
|
|
35
57
|
require 'selenium/webdriver/common/driver_extensions/has_session_id'
|
|
36
58
|
require 'selenium/webdriver/common/driver_extensions/has_touch_screen'
|
|
37
59
|
require 'selenium/webdriver/common/driver_extensions/has_remote_status'
|
|
60
|
+
require 'selenium/webdriver/common/driver_extensions/has_network_conditions'
|
|
61
|
+
require 'selenium/webdriver/common/driver_extensions/has_network_connection'
|
|
62
|
+
require 'selenium/webdriver/common/driver_extensions/has_permissions'
|
|
63
|
+
require 'selenium/webdriver/common/driver_extensions/has_debugger'
|
|
38
64
|
require 'selenium/webdriver/common/driver_extensions/uploads_files'
|
|
65
|
+
require 'selenium/webdriver/common/driver_extensions/has_addons'
|
|
66
|
+
require 'selenium/webdriver/common/interactions/interactions'
|
|
67
|
+
require 'selenium/webdriver/common/interactions/input_device'
|
|
68
|
+
require 'selenium/webdriver/common/interactions/interaction'
|
|
69
|
+
require 'selenium/webdriver/common/interactions/none_input'
|
|
70
|
+
require 'selenium/webdriver/common/interactions/key_input'
|
|
71
|
+
require 'selenium/webdriver/common/interactions/pointer_input'
|
|
39
72
|
require 'selenium/webdriver/common/keys'
|
|
40
73
|
require 'selenium/webdriver/common/bridge_helper'
|
|
41
74
|
require 'selenium/webdriver/common/profile_helper'
|
|
42
|
-
require 'selenium/webdriver/common/
|
|
75
|
+
require 'selenium/webdriver/common/options'
|
|
43
76
|
require 'selenium/webdriver/common/driver'
|
|
44
77
|
require 'selenium/webdriver/common/element'
|