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
|
@@ -1,13 +1,30 @@
|
|
|
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 private
|
|
6
24
|
#
|
|
7
25
|
|
|
8
26
|
module DriverExtensions
|
|
9
27
|
module HasSessionId
|
|
10
|
-
|
|
11
28
|
#
|
|
12
29
|
# @return [String] the session id
|
|
13
30
|
# @api public
|
|
@@ -1,10 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
|
5
|
+
# distributed with this work for additional information
|
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
|
8
|
+
# "License"); you may not use this file except in compliance
|
|
9
|
+
# with the License. You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
|
14
|
+
# software distributed under the License is distributed on an
|
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
# KIND, either express or implied. See the License for the
|
|
17
|
+
# specific language governing permissions and limitations
|
|
18
|
+
# under the License.
|
|
19
|
+
|
|
1
20
|
module Selenium
|
|
2
21
|
module WebDriver
|
|
3
22
|
module DriverExtensions
|
|
4
|
-
|
|
5
23
|
module HasTouchScreen
|
|
6
24
|
def touch
|
|
7
|
-
TouchActionBuilder.new
|
|
25
|
+
TouchActionBuilder.new Mouse.new(@bridge), Keyboard.new(@bridge), touch_screen
|
|
8
26
|
end
|
|
9
27
|
|
|
10
28
|
private
|
|
@@ -12,8 +30,7 @@ module Selenium
|
|
|
12
30
|
def touch_screen
|
|
13
31
|
TouchScreen.new @bridge
|
|
14
32
|
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
end
|
|
33
|
+
end # HasTouchScreen
|
|
34
|
+
end # DriverExtensions
|
|
35
|
+
end # WebDriver
|
|
36
|
+
end # Selenium
|
|
@@ -1,13 +1,30 @@
|
|
|
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 private
|
|
6
24
|
#
|
|
7
25
|
|
|
8
26
|
module DriverExtensions
|
|
9
27
|
module HasWebStorage
|
|
10
|
-
|
|
11
28
|
def local_storage
|
|
12
29
|
HTML5::LocalStorage.new @bridge
|
|
13
30
|
end
|
|
@@ -15,7 +32,6 @@ module Selenium
|
|
|
15
32
|
def session_storage
|
|
16
33
|
HTML5::SessionStorage.new @bridge
|
|
17
34
|
end
|
|
18
|
-
|
|
19
35
|
end # HasWebStorage
|
|
20
36
|
end # DriverExtensions
|
|
21
37
|
end # WebDriver
|
|
@@ -1,19 +1,36 @@
|
|
|
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 private
|
|
6
24
|
#
|
|
7
25
|
|
|
8
26
|
module DriverExtensions
|
|
9
27
|
module Rotatable
|
|
10
|
-
|
|
11
|
-
ORIENTATIONS = [:landscape, :portrait]
|
|
28
|
+
ORIENTATIONS = %i[landscape portrait].freeze
|
|
12
29
|
|
|
13
30
|
#
|
|
14
31
|
# Change the screen orientation
|
|
15
32
|
#
|
|
16
|
-
# @param [:landscape, :portrait]
|
|
33
|
+
# @param [:landscape, :portrait] orientation
|
|
17
34
|
#
|
|
18
35
|
# @api public
|
|
19
36
|
#
|
|
@@ -23,7 +40,7 @@ module Selenium
|
|
|
23
40
|
raise ArgumentError, "expected #{ORIENTATIONS.inspect}, got #{orientation.inspect}"
|
|
24
41
|
end
|
|
25
42
|
|
|
26
|
-
bridge.
|
|
43
|
+
bridge.screen_orientation = orientation.to_s.upcase
|
|
27
44
|
end
|
|
28
45
|
alias_method :rotate, :rotation=
|
|
29
46
|
|
|
@@ -36,9 +53,8 @@ module Selenium
|
|
|
36
53
|
#
|
|
37
54
|
|
|
38
55
|
def orientation
|
|
39
|
-
bridge.
|
|
56
|
+
bridge.screen_orientation.to_sym.downcase
|
|
40
57
|
end
|
|
41
|
-
|
|
42
58
|
end # Rotatable
|
|
43
59
|
end # DriverExtensions
|
|
44
60
|
end # WebDriver
|
|
@@ -1,13 +1,30 @@
|
|
|
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 private
|
|
6
24
|
#
|
|
7
25
|
|
|
8
26
|
module DriverExtensions
|
|
9
27
|
module TakesScreenshot
|
|
10
|
-
|
|
11
28
|
#
|
|
12
29
|
# Save a PNG screenshot to the given path
|
|
13
30
|
#
|
|
@@ -15,6 +32,11 @@ module Selenium
|
|
|
15
32
|
#
|
|
16
33
|
|
|
17
34
|
def save_screenshot(png_path)
|
|
35
|
+
extension = File.extname(png_path).downcase
|
|
36
|
+
if extension != '.png'
|
|
37
|
+
WebDriver.logger.warn "name used for saved screenshot does not match file type. "\
|
|
38
|
+
"It should end with .png extension"
|
|
39
|
+
end
|
|
18
40
|
File.open(png_path, 'wb') { |f| f << screenshot_as(:png) }
|
|
19
41
|
end
|
|
20
42
|
|
|
@@ -29,14 +51,13 @@ module Selenium
|
|
|
29
51
|
def screenshot_as(format)
|
|
30
52
|
case format
|
|
31
53
|
when :base64
|
|
32
|
-
bridge.
|
|
54
|
+
bridge.screenshot
|
|
33
55
|
when :png
|
|
34
|
-
bridge.
|
|
56
|
+
bridge.screenshot.unpack('m')[0]
|
|
35
57
|
else
|
|
36
58
|
raise Error::UnsupportedOperationError, "unsupported format: #{format.inspect}"
|
|
37
59
|
end
|
|
38
60
|
end
|
|
39
|
-
|
|
40
61
|
end # TakesScreenshot
|
|
41
62
|
end # DriverExtensions
|
|
42
63
|
end # WebDriver
|
|
@@ -1,13 +1,30 @@
|
|
|
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 private
|
|
6
24
|
#
|
|
7
25
|
|
|
8
26
|
module DriverExtensions
|
|
9
27
|
module UploadsFiles
|
|
10
|
-
|
|
11
28
|
#
|
|
12
29
|
# Set the file detector to pass local files to a remote WebDriver.
|
|
13
30
|
#
|
|
@@ -33,13 +50,10 @@ module Selenium
|
|
|
33
50
|
#
|
|
34
51
|
|
|
35
52
|
def file_detector=(detector)
|
|
36
|
-
unless detector.nil?
|
|
37
|
-
raise ArgumentError, "detector must respond to #call"
|
|
38
|
-
end
|
|
53
|
+
raise ArgumentError, 'detector must respond to #call' unless detector.nil? || detector.respond_to?(:call)
|
|
39
54
|
|
|
40
55
|
bridge.file_detector = detector
|
|
41
56
|
end
|
|
42
|
-
|
|
43
57
|
end # UploadsFiles
|
|
44
58
|
end # DriverExtensions
|
|
45
59
|
end # WebDriver
|
|
@@ -1,3 +1,22 @@
|
|
|
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 Element
|
|
@@ -10,15 +29,16 @@ module Selenium
|
|
|
10
29
|
#
|
|
11
30
|
|
|
12
31
|
def initialize(bridge, id)
|
|
13
|
-
@bridge
|
|
32
|
+
@bridge = bridge
|
|
33
|
+
@id = id
|
|
14
34
|
end
|
|
15
35
|
|
|
16
36
|
def inspect
|
|
17
|
-
'
|
|
37
|
+
format '#<%<class>s:0x%<hash>x id=%<id>s>', class: self.class, hash: hash * 2, id: @id.inspect
|
|
18
38
|
end
|
|
19
39
|
|
|
20
40
|
def ==(other)
|
|
21
|
-
other.
|
|
41
|
+
other.is_a?(self.class) && ref == other.ref
|
|
22
42
|
end
|
|
23
43
|
alias_method :eql?, :==
|
|
24
44
|
|
|
@@ -44,14 +64,14 @@ module Selenium
|
|
|
44
64
|
#
|
|
45
65
|
# @example Click on a button
|
|
46
66
|
#
|
|
47
|
-
# driver.find_element(:
|
|
67
|
+
# driver.find_element(tag_name: "button").click
|
|
48
68
|
#
|
|
49
69
|
# @raise [StaleElementReferenceError] if the element no longer exists as
|
|
50
70
|
# defined
|
|
51
71
|
#
|
|
52
72
|
|
|
53
73
|
def click
|
|
54
|
-
bridge.
|
|
74
|
+
bridge.click_element @id
|
|
55
75
|
end
|
|
56
76
|
|
|
57
77
|
#
|
|
@@ -59,13 +79,13 @@ module Selenium
|
|
|
59
79
|
#
|
|
60
80
|
# @example Get the tagname of an INPUT element(returns "input")
|
|
61
81
|
#
|
|
62
|
-
# driver.find_element(:
|
|
82
|
+
# driver.find_element(xpath: "//input").tag_name
|
|
63
83
|
#
|
|
64
84
|
# @return [String] The tag name of this element.
|
|
65
85
|
#
|
|
66
86
|
|
|
67
87
|
def tag_name
|
|
68
|
-
bridge.
|
|
88
|
+
bridge.element_tag_name @id
|
|
69
89
|
end
|
|
70
90
|
|
|
71
91
|
#
|
|
@@ -88,14 +108,24 @@ module Selenium
|
|
|
88
108
|
#
|
|
89
109
|
# class, readonly
|
|
90
110
|
#
|
|
91
|
-
# @param [String]
|
|
92
|
-
#
|
|
93
|
-
# @return [String,nil]
|
|
94
|
-
# attribute value
|
|
111
|
+
# @param [String] name attribute name
|
|
112
|
+
# @return [String, nil] attribute value
|
|
95
113
|
#
|
|
96
114
|
|
|
97
115
|
def attribute(name)
|
|
98
|
-
bridge.
|
|
116
|
+
bridge.element_attribute self, name
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
#
|
|
120
|
+
# Get the value of a the given property with the same name of the element. If the value is not
|
|
121
|
+
# set, nil is returned.
|
|
122
|
+
#
|
|
123
|
+
# @param [String] name property name
|
|
124
|
+
# @return [String, nil] property value
|
|
125
|
+
#
|
|
126
|
+
|
|
127
|
+
def property(name)
|
|
128
|
+
bridge.element_property self, name
|
|
99
129
|
end
|
|
100
130
|
|
|
101
131
|
#
|
|
@@ -105,13 +135,13 @@ module Selenium
|
|
|
105
135
|
#
|
|
106
136
|
|
|
107
137
|
def text
|
|
108
|
-
bridge.
|
|
138
|
+
bridge.element_text @id
|
|
109
139
|
end
|
|
110
140
|
|
|
111
141
|
#
|
|
112
142
|
# Send keystrokes to this element
|
|
113
143
|
#
|
|
114
|
-
# @param [String, Symbol, Array]
|
|
144
|
+
# @param [String, Symbol, Array] args keystrokes to send
|
|
115
145
|
#
|
|
116
146
|
# Examples:
|
|
117
147
|
#
|
|
@@ -123,7 +153,7 @@ module Selenium
|
|
|
123
153
|
#
|
|
124
154
|
|
|
125
155
|
def send_keys(*args)
|
|
126
|
-
bridge.
|
|
156
|
+
bridge.send_keys_to_element @id, Keys.encode(args)
|
|
127
157
|
end
|
|
128
158
|
alias_method :send_key, :send_keys
|
|
129
159
|
|
|
@@ -133,12 +163,12 @@ module Selenium
|
|
|
133
163
|
#
|
|
134
164
|
# Note that the events fired by this event may not be as you'd expect. In particular, we don't
|
|
135
165
|
# fire any keyboard or mouse events. If you want to ensure keyboard events are
|
|
136
|
-
# fired, consider using #send_keys with the backspace key. To ensure you get a change event,
|
|
166
|
+
# fired, consider using #send_keys with the backspace key. To ensure you get a change event,
|
|
137
167
|
# consider following with a call to #send_keys with the tab key.
|
|
138
168
|
#
|
|
139
169
|
|
|
140
170
|
def clear
|
|
141
|
-
bridge.
|
|
171
|
+
bridge.clear_element @id
|
|
142
172
|
end
|
|
143
173
|
|
|
144
174
|
#
|
|
@@ -148,7 +178,7 @@ module Selenium
|
|
|
148
178
|
#
|
|
149
179
|
|
|
150
180
|
def enabled?
|
|
151
|
-
bridge.
|
|
181
|
+
bridge.element_enabled? @id
|
|
152
182
|
end
|
|
153
183
|
|
|
154
184
|
#
|
|
@@ -158,7 +188,7 @@ module Selenium
|
|
|
158
188
|
#
|
|
159
189
|
|
|
160
190
|
def selected?
|
|
161
|
-
bridge.
|
|
191
|
+
bridge.element_selected? @id
|
|
162
192
|
end
|
|
163
193
|
|
|
164
194
|
#
|
|
@@ -168,7 +198,7 @@ module Selenium
|
|
|
168
198
|
#
|
|
169
199
|
|
|
170
200
|
def displayed?
|
|
171
|
-
bridge.
|
|
201
|
+
bridge.element_displayed? self
|
|
172
202
|
end
|
|
173
203
|
|
|
174
204
|
#
|
|
@@ -176,7 +206,7 @@ module Selenium
|
|
|
176
206
|
#
|
|
177
207
|
|
|
178
208
|
def submit
|
|
179
|
-
bridge.
|
|
209
|
+
bridge.submit_element @id
|
|
180
210
|
end
|
|
181
211
|
|
|
182
212
|
#
|
|
@@ -191,7 +221,7 @@ module Selenium
|
|
|
191
221
|
#
|
|
192
222
|
|
|
193
223
|
def css_value(prop)
|
|
194
|
-
bridge.
|
|
224
|
+
bridge.element_value_of_css_property @id, prop
|
|
195
225
|
end
|
|
196
226
|
alias_method :style, :css_value
|
|
197
227
|
|
|
@@ -202,7 +232,17 @@ module Selenium
|
|
|
202
232
|
#
|
|
203
233
|
|
|
204
234
|
def location
|
|
205
|
-
bridge.
|
|
235
|
+
bridge.element_location @id
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
#
|
|
239
|
+
# Get the dimensions and coordinates of this element.
|
|
240
|
+
#
|
|
241
|
+
# @return [WebDriver::Rectangle]
|
|
242
|
+
#
|
|
243
|
+
|
|
244
|
+
def rect
|
|
245
|
+
bridge.element_rect @id
|
|
206
246
|
end
|
|
207
247
|
|
|
208
248
|
#
|
|
@@ -212,7 +252,7 @@ module Selenium
|
|
|
212
252
|
#
|
|
213
253
|
|
|
214
254
|
def location_once_scrolled_into_view
|
|
215
|
-
bridge.
|
|
255
|
+
bridge.element_location_once_scrolled_into_view @id
|
|
216
256
|
end
|
|
217
257
|
|
|
218
258
|
#
|
|
@@ -222,19 +262,19 @@ module Selenium
|
|
|
222
262
|
#
|
|
223
263
|
|
|
224
264
|
def size
|
|
225
|
-
bridge.
|
|
265
|
+
bridge.element_size @id
|
|
226
266
|
end
|
|
227
267
|
|
|
228
268
|
#-------------------------------- sugar --------------------------------
|
|
229
269
|
|
|
230
270
|
#
|
|
231
|
-
# element.first(:
|
|
271
|
+
# element.first(id: 'foo')
|
|
232
272
|
#
|
|
233
273
|
|
|
234
274
|
alias_method :first, :find_element
|
|
235
275
|
|
|
236
276
|
#
|
|
237
|
-
# element.all(:
|
|
277
|
+
# element.all(class: 'bar')
|
|
238
278
|
#
|
|
239
279
|
|
|
240
280
|
alias_method :all, :find_elements
|
|
@@ -256,13 +296,13 @@ module Selenium
|
|
|
256
296
|
|
|
257
297
|
#
|
|
258
298
|
# Convert to a WebElement JSON Object for transmission over the wire.
|
|
259
|
-
# @see
|
|
299
|
+
# @see https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#basic-terms-and-concepts
|
|
260
300
|
#
|
|
261
301
|
# @api private
|
|
262
302
|
#
|
|
263
303
|
|
|
264
|
-
def to_json(*
|
|
265
|
-
|
|
304
|
+
def to_json(*)
|
|
305
|
+
JSON.generate as_json
|
|
266
306
|
end
|
|
267
307
|
|
|
268
308
|
#
|
|
@@ -271,23 +311,25 @@ module Selenium
|
|
|
271
311
|
# @api private
|
|
272
312
|
#
|
|
273
313
|
|
|
274
|
-
def as_json(
|
|
275
|
-
|
|
314
|
+
def as_json(*)
|
|
315
|
+
key = if bridge.dialect == :w3c
|
|
316
|
+
'element-6066-11e4-a52e-4f735466cecf'
|
|
317
|
+
else
|
|
318
|
+
'ELEMENT'
|
|
319
|
+
end
|
|
320
|
+
@id.is_a?(Hash) ? @id : {key => @id}
|
|
276
321
|
end
|
|
277
322
|
|
|
278
323
|
private
|
|
279
324
|
|
|
280
|
-
|
|
281
|
-
@bridge
|
|
282
|
-
end
|
|
325
|
+
attr_reader :bridge
|
|
283
326
|
|
|
284
327
|
def selectable?
|
|
285
328
|
tn = tag_name.downcase
|
|
286
329
|
type = attribute(:type).to_s.downcase
|
|
287
330
|
|
|
288
|
-
tn ==
|
|
331
|
+
tn == 'option' || (tn == 'input' && %w[radio checkbox].include?(type))
|
|
289
332
|
end
|
|
290
|
-
|
|
291
333
|
end # Element
|
|
292
334
|
end # WebDriver
|
|
293
335
|
end # Selenium
|