selenium-webdriver 3.142.7 → 4.3.0
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 +5 -5
- data/CHANGES +432 -5
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/NOTICE +2 -0
- data/README.md +4 -5
- data/lib/selenium/server.rb +75 -64
- data/lib/selenium/webdriver/atoms/findElements.js +122 -0
- data/lib/selenium/webdriver/atoms/getAttribute.js +100 -7
- data/lib/selenium/webdriver/atoms/isDisplayed.js +76 -78
- data/lib/selenium/webdriver/atoms/mutationListener.js +55 -0
- data/lib/selenium/webdriver/bidi/session.rb +38 -0
- data/lib/selenium/webdriver/bidi.rb +55 -0
- data/lib/selenium/webdriver/chrome/driver.rb +26 -83
- data/lib/selenium/webdriver/chrome/{bridge.rb → features.rb} +55 -12
- data/lib/selenium/webdriver/chrome/options.rb +138 -67
- data/lib/selenium/webdriver/chrome/profile.rb +6 -3
- data/lib/selenium/webdriver/chrome/service.rb +8 -15
- data/lib/selenium/webdriver/chrome.rb +5 -18
- data/lib/selenium/webdriver/common/action_builder.rb +171 -236
- data/lib/selenium/webdriver/common/driver.rb +76 -29
- data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +43 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +89 -0
- data/lib/selenium/webdriver/common/driver_extensions/{has_touch_screen.rb → has_bidi.rb} +10 -8
- data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +87 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +38 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +44 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +43 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +38 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +5 -8
- data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +144 -0
- data/lib/selenium/webdriver/common/driver_extensions/{has_remote_status.rb → has_logs.rb} +4 -4
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +17 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +6 -27
- data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +136 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +11 -11
- data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +77 -0
- data/lib/selenium/webdriver/common/driver_extensions/{rotatable.rb → prints_page.rb} +18 -20
- data/lib/selenium/webdriver/common/element.rb +83 -23
- data/lib/selenium/webdriver/common/error.rb +32 -196
- data/lib/selenium/webdriver/common/interactions/input_device.rb +10 -4
- data/lib/selenium/webdriver/common/interactions/interaction.rb +12 -22
- data/lib/selenium/webdriver/common/interactions/interactions.rb +24 -4
- data/lib/selenium/webdriver/common/interactions/key_actions.rb +10 -6
- data/lib/selenium/webdriver/common/interactions/key_input.rb +11 -27
- data/lib/selenium/webdriver/common/interactions/none_input.rb +10 -8
- data/lib/selenium/webdriver/common/interactions/pause.rb +49 -0
- data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +68 -78
- data/lib/selenium/webdriver/common/interactions/pointer_cancel.rb +45 -0
- data/lib/selenium/webdriver/common/interactions/pointer_event_properties.rb +63 -0
- data/lib/selenium/webdriver/common/interactions/pointer_input.rb +15 -84
- data/lib/selenium/webdriver/common/interactions/pointer_move.rb +60 -0
- data/lib/selenium/webdriver/common/interactions/pointer_press.rb +85 -0
- data/lib/selenium/webdriver/common/interactions/scroll.rb +57 -0
- data/lib/selenium/webdriver/common/interactions/scroll_origin.rb +48 -0
- data/lib/selenium/webdriver/common/interactions/typing_interaction.rb +54 -0
- data/lib/selenium/webdriver/common/interactions/wheel_actions.rb +113 -0
- data/lib/selenium/webdriver/common/{w3c_manager.rb → interactions/wheel_input.rb} +14 -17
- data/lib/selenium/webdriver/common/keys.rb +1 -0
- data/lib/selenium/webdriver/common/log_entry.rb +2 -2
- data/lib/selenium/webdriver/common/logger.rb +50 -15
- data/lib/selenium/webdriver/common/manager.rb +11 -38
- data/lib/selenium/webdriver/common/options.rb +147 -23
- data/lib/selenium/webdriver/common/platform.rb +10 -5
- data/lib/selenium/webdriver/common/port_prober.rb +4 -6
- data/lib/selenium/webdriver/common/profile_helper.rb +11 -9
- data/lib/selenium/webdriver/common/proxy.rb +6 -3
- data/lib/selenium/webdriver/common/search_context.rb +7 -9
- data/lib/selenium/webdriver/common/service.rb +17 -125
- data/lib/selenium/webdriver/common/service_manager.rb +150 -0
- data/lib/selenium/webdriver/common/shadow_root.rb +87 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +2 -2
- data/lib/selenium/webdriver/common/socket_poller.rb +3 -3
- data/lib/selenium/webdriver/common/takes_screenshot.rb +66 -0
- data/lib/selenium/webdriver/common/target_locator.rb +32 -4
- data/lib/selenium/webdriver/common/timeouts.rb +31 -4
- data/lib/selenium/webdriver/common/wait.rb +1 -1
- data/lib/selenium/webdriver/common/websocket_connection.rb +149 -0
- data/lib/selenium/webdriver/common/window.rb +0 -4
- data/lib/selenium/webdriver/common/zipper.rb +3 -9
- data/lib/selenium/webdriver/common.rb +35 -18
- data/lib/selenium/webdriver/devtools/console_event.rb +38 -0
- data/lib/selenium/webdriver/devtools/exception_event.rb +36 -0
- data/lib/selenium/webdriver/devtools/mutation_event.rb +37 -0
- data/lib/selenium/webdriver/devtools/pinned_script.rb +59 -0
- data/lib/selenium/webdriver/devtools/request.rb +67 -0
- data/lib/selenium/webdriver/devtools/response.rb +66 -0
- data/lib/selenium/webdriver/devtools.rb +86 -0
- data/lib/selenium/webdriver/edge/driver.rb +7 -29
- data/lib/selenium/webdriver/edge/features.rb +45 -0
- data/lib/selenium/webdriver/edge/options.rb +11 -48
- data/lib/selenium/webdriver/edge/profile.rb +33 -0
- data/lib/selenium/webdriver/edge/service.rb +10 -26
- data/lib/selenium/webdriver/edge.rb +11 -14
- data/lib/selenium/webdriver/firefox/driver.rb +32 -19
- data/lib/selenium/webdriver/firefox/extension.rb +8 -0
- data/lib/selenium/webdriver/firefox/features.rb +63 -0
- data/lib/selenium/webdriver/firefox/options.rb +73 -50
- data/lib/selenium/webdriver/firefox/profile.rb +16 -70
- data/lib/selenium/webdriver/firefox/service.rb +5 -9
- data/lib/selenium/webdriver/firefox/util.rb +1 -1
- data/lib/selenium/webdriver/firefox.rb +17 -28
- data/lib/selenium/webdriver/ie/driver.rb +1 -47
- data/lib/selenium/webdriver/ie/options.rb +15 -46
- data/lib/selenium/webdriver/ie/service.rb +13 -15
- data/lib/selenium/webdriver/ie.rb +3 -16
- data/lib/selenium/webdriver/remote/bridge.rb +563 -86
- data/lib/selenium/webdriver/remote/capabilities.rb +159 -123
- data/lib/selenium/webdriver/remote/commands.rb +158 -0
- data/lib/selenium/webdriver/remote/driver.rb +22 -13
- data/lib/selenium/webdriver/remote/http/common.rb +0 -5
- data/lib/selenium/webdriver/remote/http/default.rb +22 -31
- data/lib/selenium/webdriver/remote/response.rb +18 -49
- data/lib/selenium/webdriver/remote.rb +15 -12
- data/lib/selenium/webdriver/safari/driver.rb +3 -31
- data/lib/selenium/webdriver/safari/{bridge.rb → features.rb} +3 -3
- data/lib/selenium/webdriver/safari/options.rb +10 -29
- data/lib/selenium/webdriver/safari/service.rb +4 -8
- data/lib/selenium/webdriver/safari.rb +13 -19
- data/lib/selenium/webdriver/support/block_event_listener.rb +1 -1
- data/lib/selenium/webdriver/support/cdp/domain.rb.erb +63 -0
- data/lib/selenium/webdriver/support/cdp_client_generator.rb +108 -0
- data/lib/selenium/webdriver/support/color.rb +9 -9
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +4 -4
- data/lib/selenium/webdriver/support/guards/guard.rb +89 -0
- data/lib/selenium/webdriver/{firefox/marionette/bridge.rb → support/guards/guard_condition.rb} +22 -19
- data/lib/selenium/webdriver/support/guards.rb +95 -0
- data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
- data/lib/selenium/webdriver/support/select.rb +3 -3
- data/lib/selenium/webdriver/support.rb +1 -0
- data/lib/selenium/webdriver/version.rb +1 -1
- data/lib/selenium/webdriver.rb +14 -13
- data/selenium-webdriver.gemspec +32 -13
- metadata +176 -69
- data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +0 -64
- data/lib/selenium/webdriver/common/keyboard.rb +0 -70
- data/lib/selenium/webdriver/common/mouse.rb +0 -89
- data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -78
- data/lib/selenium/webdriver/common/touch_screen.rb +0 -123
- data/lib/selenium/webdriver/common/w3c_action_builder.rb +0 -212
- data/lib/selenium/webdriver/edge/bridge.rb +0 -76
- data/lib/selenium/webdriver/firefox/binary.rb +0 -187
- data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +0 -111
- data/lib/selenium/webdriver/firefox/legacy/driver.rb +0 -83
- data/lib/selenium/webdriver/firefox/marionette/driver.rb +0 -90
- data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/remote/http/persistent.rb +0 -60
- data/lib/selenium/webdriver/remote/oss/bridge.rb +0 -594
- data/lib/selenium/webdriver/remote/oss/commands.rb +0 -223
- data/lib/selenium/webdriver/remote/w3c/bridge.rb +0 -605
- data/lib/selenium/webdriver/remote/w3c/capabilities.rb +0 -310
- data/lib/selenium/webdriver/remote/w3c/commands.rb +0 -157
|
@@ -22,7 +22,7 @@ module Selenium
|
|
|
22
22
|
module KeyActions
|
|
23
23
|
#
|
|
24
24
|
# Performs a key press. Does not release the key - subsequent interactions may assume it's kept pressed.
|
|
25
|
-
# Note that the key is never released implicitly - either
|
|
25
|
+
# Note that the key is never released implicitly - either ActionBuilder#key_up(key) or ActionBuilder#release_actions
|
|
26
26
|
# must be called to release the key.
|
|
27
27
|
#
|
|
28
28
|
# @example Press a key
|
|
@@ -41,7 +41,7 @@ module Selenium
|
|
|
41
41
|
# @param [Element] element An optional element to move to first
|
|
42
42
|
# @param [Symbol, String] key The key to press
|
|
43
43
|
# @param [Symbol, String] device Optional name of the KeyInput device to press the key on
|
|
44
|
-
# @return [
|
|
44
|
+
# @return [ActionBuilder] A self reference
|
|
45
45
|
#
|
|
46
46
|
|
|
47
47
|
def key_down(*args, device: nil)
|
|
@@ -68,7 +68,7 @@ module Selenium
|
|
|
68
68
|
# @param [Element] element An optional element to move to first
|
|
69
69
|
# @param [Symbol, String] key The key to release
|
|
70
70
|
# @param [Symbol, String] device Optional name of the KeyInput device to release the key on
|
|
71
|
-
# @return [
|
|
71
|
+
# @return [ActionBuilder] A self reference
|
|
72
72
|
#
|
|
73
73
|
|
|
74
74
|
def key_up(*args, device: nil)
|
|
@@ -98,7 +98,7 @@ module Selenium
|
|
|
98
98
|
# @param [Element] element An optional element to move to first
|
|
99
99
|
# @param [Array, Symbol, String] keys The key(s) to press and release
|
|
100
100
|
# @param [Symbol, String] device Optional name of the KeyInput device to press and release the keys on
|
|
101
|
-
# @return [
|
|
101
|
+
# @return [ActionBuilder] A self reference
|
|
102
102
|
#
|
|
103
103
|
|
|
104
104
|
def send_keys(*args, device: nil)
|
|
@@ -130,16 +130,20 @@ module Selenium
|
|
|
130
130
|
# @option args [Symbol, String] key The key to perform the action with
|
|
131
131
|
# @param [Symbol] action The name of the key action to perform
|
|
132
132
|
# @param [Symbol, String] device optional name of the KeyInput device to press the key on
|
|
133
|
-
# @return [
|
|
133
|
+
# @return [ActionBuilder] A self reference
|
|
134
134
|
#
|
|
135
135
|
|
|
136
136
|
def key_action(*args, action: nil, device: nil)
|
|
137
|
-
key_input =
|
|
137
|
+
key_input = key_input(device)
|
|
138
138
|
click(args.shift) if args.first.is_a? Element
|
|
139
139
|
key_input.send(action, args.last)
|
|
140
140
|
tick(key_input)
|
|
141
141
|
self
|
|
142
142
|
end
|
|
143
|
+
|
|
144
|
+
def key_input(name = nil)
|
|
145
|
+
device(name: name, type: Interactions::KEY) || add_key_input('keyboard')
|
|
146
|
+
end
|
|
143
147
|
end # KeyActions
|
|
144
148
|
end # WebDriver
|
|
145
149
|
end # Selenium
|
|
@@ -20,17 +20,18 @@
|
|
|
20
20
|
module Selenium
|
|
21
21
|
module WebDriver
|
|
22
22
|
module Interactions
|
|
23
|
+
#
|
|
24
|
+
# Creates actions specific to Key Input devices
|
|
25
|
+
#
|
|
26
|
+
# @api private
|
|
27
|
+
#
|
|
28
|
+
|
|
23
29
|
class KeyInput < InputDevice
|
|
24
30
|
SUBTYPES = {down: :keyDown, up: :keyUp, pause: :pause}.freeze
|
|
25
31
|
|
|
26
|
-
def
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def encode
|
|
31
|
-
return nil if no_actions?
|
|
32
|
-
|
|
33
|
-
{type: type, id: name, actions: @actions.map(&:encode)}
|
|
32
|
+
def initialize(name = nil)
|
|
33
|
+
super
|
|
34
|
+
@type = Interactions::KEY
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
def create_key_down(key)
|
|
@@ -41,25 +42,8 @@ module Selenium
|
|
|
41
42
|
add_action(TypingInteraction.new(self, :up, key))
|
|
42
43
|
end
|
|
43
44
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
def initialize(source, type, key)
|
|
48
|
-
super(source)
|
|
49
|
-
@type = assert_type(type)
|
|
50
|
-
@key = Keys.encode_key(key)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def assert_type(type)
|
|
54
|
-
raise TypeError, "#{type.inspect} is not a valid key subtype" unless KeyInput::SUBTYPES.key? type
|
|
55
|
-
|
|
56
|
-
KeyInput::SUBTYPES[type]
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def encode
|
|
60
|
-
{type: @type, value: @key}
|
|
61
|
-
end
|
|
62
|
-
end # TypingInteraction
|
|
45
|
+
# Backward compatibility in case anyone called this directly
|
|
46
|
+
class TypingInteraction < Interactions::TypingInteraction; end
|
|
63
47
|
end # KeyInput
|
|
64
48
|
end # Interactions
|
|
65
49
|
end # WebDriver
|
|
@@ -20,15 +20,17 @@
|
|
|
20
20
|
module Selenium
|
|
21
21
|
module WebDriver
|
|
22
22
|
module Interactions
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
#
|
|
24
|
+
# Creates actions specific to null input source
|
|
25
|
+
# This is primarily used for adding pauses
|
|
26
|
+
#
|
|
27
|
+
# @api private
|
|
28
|
+
#
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
class NoneInput < InputDevice
|
|
31
|
+
def initialize(name = nil)
|
|
32
|
+
super
|
|
33
|
+
@type = Interactions::NONE
|
|
32
34
|
end
|
|
33
35
|
end # NoneInput
|
|
34
36
|
end # Interactions
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
module Interactions
|
|
23
|
+
#
|
|
24
|
+
# Action to create a waiting period between actions
|
|
25
|
+
# Also used for synchronizing actions across devices
|
|
26
|
+
#
|
|
27
|
+
# @api private
|
|
28
|
+
#
|
|
29
|
+
|
|
30
|
+
class Pause < Interaction
|
|
31
|
+
def initialize(source, duration = nil)
|
|
32
|
+
super(source)
|
|
33
|
+
@duration = duration
|
|
34
|
+
@type = :pause
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def assert_source(source)
|
|
38
|
+
raise TypeError, "#{source.type} is not a valid input type" unless source.is_a? InputDevice
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def encode
|
|
42
|
+
output = {type: type}
|
|
43
|
+
output[:duration] = (@duration * 1000).to_i if @duration
|
|
44
|
+
output
|
|
45
|
+
end
|
|
46
|
+
end # Pause
|
|
47
|
+
end # Interactions
|
|
48
|
+
end # WebDriver
|
|
49
|
+
end # Selenium
|
|
@@ -23,11 +23,12 @@ module Selenium
|
|
|
23
23
|
attr_writer :default_move_duration
|
|
24
24
|
|
|
25
25
|
#
|
|
26
|
-
#
|
|
26
|
+
# By default this is set to 250ms in the ActionBuilder constructor
|
|
27
|
+
# It can be overridden with default_move_duration=
|
|
27
28
|
#
|
|
28
29
|
|
|
29
30
|
def default_move_duration
|
|
30
|
-
@default_move_duration ||= 0
|
|
31
|
+
@default_move_duration ||= @duration / 1000.0 # convert ms to seconds
|
|
31
32
|
end
|
|
32
33
|
|
|
33
34
|
#
|
|
@@ -42,11 +43,11 @@ module Selenium
|
|
|
42
43
|
# @param [Selenium::WebDriver::Interactions::PointerPress::BUTTONS] button the button to press.
|
|
43
44
|
# @param [Symbol || String] device optional name of the PointerInput device with the button
|
|
44
45
|
# that will be pressed
|
|
45
|
-
# @return [
|
|
46
|
+
# @return [ActionBuilder] A self reference.
|
|
46
47
|
#
|
|
47
48
|
|
|
48
|
-
def pointer_down(button, device: nil)
|
|
49
|
-
button_action(button,
|
|
49
|
+
def pointer_down(button = :left, device: nil, **opts)
|
|
50
|
+
button_action(button, :create_pointer_down, device: device, **opts)
|
|
50
51
|
end
|
|
51
52
|
|
|
52
53
|
#
|
|
@@ -59,24 +60,24 @@ module Selenium
|
|
|
59
60
|
# @param [Selenium::WebDriver::Interactions::PointerPress::BUTTONS] button the button to release.
|
|
60
61
|
# @param [Symbol || String] device optional name of the PointerInput device with the button that will
|
|
61
62
|
# be released
|
|
62
|
-
# @return [
|
|
63
|
+
# @return [ActionBuilder] A self reference.
|
|
63
64
|
#
|
|
64
65
|
|
|
65
|
-
def pointer_up(button, device: nil)
|
|
66
|
-
button_action(button,
|
|
66
|
+
def pointer_up(button = :left, device: nil, **opts)
|
|
67
|
+
button_action(button, :create_pointer_up, device: device, **opts)
|
|
67
68
|
end
|
|
68
69
|
|
|
69
70
|
#
|
|
70
|
-
# Moves the
|
|
71
|
-
#
|
|
72
|
-
#
|
|
71
|
+
# Moves the pointer to the middle of the given element.
|
|
72
|
+
# its location is calculated using getBoundingClientRect.
|
|
73
|
+
# Then the pointer is moved to optional offset coordinates from the element.
|
|
73
74
|
#
|
|
74
|
-
#
|
|
75
|
-
#
|
|
75
|
+
# The element is not scrolled into view.
|
|
76
|
+
# MoveTargetOutOfBoundsError will be raised if element with offset is outside the viewport
|
|
76
77
|
#
|
|
77
|
-
#
|
|
78
|
+
# When using offsets, both coordinates need to be passed.
|
|
78
79
|
#
|
|
79
|
-
# @example
|
|
80
|
+
# @example Move the pointer to element
|
|
80
81
|
#
|
|
81
82
|
# el = driver.find_element(id: "some_id")
|
|
82
83
|
# driver.action.move_to(el).perform
|
|
@@ -92,80 +93,72 @@ module Selenium
|
|
|
92
93
|
# @param [Integer] down_by Optional offset from the top-left corner. A negative value means
|
|
93
94
|
# coordinates above the element.
|
|
94
95
|
# @param [Symbol || String] device optional name of the PointerInput device to move.
|
|
95
|
-
# @return [
|
|
96
|
+
# @return [ActionBuilder] A self reference.
|
|
96
97
|
#
|
|
97
98
|
|
|
98
|
-
def move_to(element, right_by = nil, down_by = nil, device: nil)
|
|
99
|
-
pointer =
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
left = -left_offset + (right_by || 0)
|
|
106
|
-
top = -top_offset + (down_by || 0)
|
|
107
|
-
else
|
|
108
|
-
left = 0
|
|
109
|
-
top = 0
|
|
110
|
-
end
|
|
111
|
-
pointer.create_pointer_move(duration: default_move_duration,
|
|
112
|
-
x: left,
|
|
113
|
-
y: top,
|
|
114
|
-
element: element)
|
|
99
|
+
def move_to(element, right_by = nil, down_by = nil, device: nil, duration: default_move_duration, **opts)
|
|
100
|
+
pointer = pointer_input(device)
|
|
101
|
+
pointer.create_pointer_move(duration: duration,
|
|
102
|
+
x: right_by || 0,
|
|
103
|
+
y: down_by || 0,
|
|
104
|
+
origin: element,
|
|
105
|
+
**opts)
|
|
115
106
|
tick(pointer)
|
|
116
107
|
self
|
|
117
108
|
end
|
|
118
109
|
|
|
119
110
|
#
|
|
120
|
-
# Moves the
|
|
121
|
-
# If the coordinates provided are outside the viewport (the mouse will
|
|
122
|
-
# end up outside the browser window) then the viewport is scrolled to
|
|
123
|
-
# match.
|
|
111
|
+
# Moves the pointer from its current position by the given offset.
|
|
124
112
|
#
|
|
125
|
-
#
|
|
113
|
+
# The viewport is not scrolled if the coordinates provided are outside the viewport.
|
|
114
|
+
# MoveTargetOutOfBoundsError will be raised if the offsets are outside the viewport
|
|
115
|
+
#
|
|
116
|
+
# @example Move the pointer to a certain offset from its current position
|
|
126
117
|
#
|
|
127
118
|
# driver.action.move_by(100, 100).perform
|
|
128
119
|
#
|
|
129
|
-
# @param [Integer] right_by horizontal offset. A negative value means moving the
|
|
130
|
-
# @param [Integer] down_by vertical offset. A negative value means moving the
|
|
120
|
+
# @param [Integer] right_by horizontal offset. A negative value means moving the pointer left.
|
|
121
|
+
# @param [Integer] down_by vertical offset. A negative value means moving the pointer up.
|
|
131
122
|
# @param [Symbol || String] device optional name of the PointerInput device to move
|
|
132
|
-
# @return [
|
|
123
|
+
# @return [ActionBuilder] A self reference.
|
|
133
124
|
# @raise [MoveTargetOutOfBoundsError] if the provided offset is outside the document's boundaries.
|
|
134
125
|
#
|
|
135
126
|
|
|
136
|
-
def move_by(right_by, down_by, device: nil)
|
|
137
|
-
pointer =
|
|
138
|
-
pointer.create_pointer_move(duration:
|
|
127
|
+
def move_by(right_by, down_by, device: nil, duration: default_move_duration, **opts)
|
|
128
|
+
pointer = pointer_input(device)
|
|
129
|
+
pointer.create_pointer_move(duration: duration,
|
|
139
130
|
x: Integer(right_by),
|
|
140
131
|
y: Integer(down_by),
|
|
141
|
-
origin: Interactions::PointerMove::POINTER
|
|
132
|
+
origin: Interactions::PointerMove::POINTER,
|
|
133
|
+
**opts)
|
|
142
134
|
tick(pointer)
|
|
143
135
|
self
|
|
144
136
|
end
|
|
145
137
|
|
|
146
138
|
#
|
|
147
|
-
# Moves the
|
|
148
|
-
#
|
|
149
|
-
#
|
|
150
|
-
#
|
|
139
|
+
# Moves the pointer to a given location in the viewport.
|
|
140
|
+
#
|
|
141
|
+
# The viewport is not scrolled if the coordinates provided are outside the viewport.
|
|
142
|
+
# MoveTargetOutOfBoundsError will be raised if the offsets are outside the viewport
|
|
151
143
|
#
|
|
152
|
-
# @example Move the
|
|
144
|
+
# @example Move the pointer to a certain position in the viewport
|
|
153
145
|
#
|
|
154
146
|
# driver.action.move_to_location(100, 100).perform
|
|
155
147
|
#
|
|
156
148
|
# @param [Integer] x horizontal position. Equivalent to a css 'left' value.
|
|
157
149
|
# @param [Integer] y vertical position. Equivalent to a css 'top' value.
|
|
158
150
|
# @param [Symbol || String] device optional name of the PointerInput device to move
|
|
159
|
-
# @return [
|
|
151
|
+
# @return [ActionBuilder] A self reference.
|
|
160
152
|
# @raise [MoveTargetOutOfBoundsError] if the provided x or y value is outside the document's boundaries.
|
|
161
153
|
#
|
|
162
154
|
|
|
163
|
-
def move_to_location(x, y, device: nil)
|
|
164
|
-
pointer =
|
|
165
|
-
pointer.create_pointer_move(duration:
|
|
155
|
+
def move_to_location(x, y, device: nil, duration: default_move_duration, **opts)
|
|
156
|
+
pointer = pointer_input(device)
|
|
157
|
+
pointer.create_pointer_move(duration: duration,
|
|
166
158
|
x: Integer(x),
|
|
167
159
|
y: Integer(y),
|
|
168
|
-
origin: Interactions::PointerMove::VIEWPORT
|
|
160
|
+
origin: Interactions::PointerMove::VIEWPORT,
|
|
161
|
+
**opts)
|
|
169
162
|
tick(pointer)
|
|
170
163
|
self
|
|
171
164
|
end
|
|
@@ -183,12 +176,12 @@ module Selenium
|
|
|
183
176
|
#
|
|
184
177
|
# @param [Selenium::WebDriver::Element] element the element to move to and click.
|
|
185
178
|
# @param [Symbol || String] device optional name of the PointerInput device to click with
|
|
186
|
-
# @return [
|
|
179
|
+
# @return [ActionBuilder] A self reference.
|
|
187
180
|
#
|
|
188
181
|
|
|
189
|
-
def click_and_hold(element = nil, device: nil)
|
|
182
|
+
def click_and_hold(element = nil, button: nil, device: nil)
|
|
190
183
|
move_to(element, device: device) if element
|
|
191
|
-
pointer_down(:left, device: device)
|
|
184
|
+
pointer_down(button || :left, device: device)
|
|
192
185
|
self
|
|
193
186
|
end
|
|
194
187
|
|
|
@@ -202,11 +195,11 @@ module Selenium
|
|
|
202
195
|
#
|
|
203
196
|
# @param [Symbol || String] device optional name of the PointerInput device with the button
|
|
204
197
|
# that will be released
|
|
205
|
-
# @return [
|
|
198
|
+
# @return [ActionBuilder] A self reference.
|
|
206
199
|
#
|
|
207
200
|
|
|
208
|
-
def release(device: nil)
|
|
209
|
-
pointer_up(:left, device: device)
|
|
201
|
+
def release(button: nil, device: nil)
|
|
202
|
+
pointer_up(button || :left, device: device)
|
|
210
203
|
self
|
|
211
204
|
end
|
|
212
205
|
|
|
@@ -229,13 +222,13 @@ module Selenium
|
|
|
229
222
|
# @param [Selenium::WebDriver::Element] element An optional element to click.
|
|
230
223
|
# @param [Symbol || String] device optional name of the PointerInput device with the button
|
|
231
224
|
# that will be clicked
|
|
232
|
-
# @return [
|
|
225
|
+
# @return [ActionBuilder] A self reference.
|
|
233
226
|
#
|
|
234
227
|
|
|
235
|
-
def click(element = nil, device: nil)
|
|
228
|
+
def click(element = nil, button: nil, device: nil)
|
|
236
229
|
move_to(element, device: device) if element
|
|
237
|
-
pointer_down(:left, device: device)
|
|
238
|
-
pointer_up(:left, device: device)
|
|
230
|
+
pointer_down(button || :left, device: device)
|
|
231
|
+
pointer_up(button || :left, device: device)
|
|
239
232
|
self
|
|
240
233
|
end
|
|
241
234
|
|
|
@@ -258,7 +251,7 @@ module Selenium
|
|
|
258
251
|
# @param [Selenium::WebDriver::Element] element An optional element to move to.
|
|
259
252
|
# @param [Symbol || String] device optional name of the PointerInput device with the button
|
|
260
253
|
# that will be double-clicked
|
|
261
|
-
# @return [
|
|
254
|
+
# @return [ActionBuilder] A self reference.
|
|
262
255
|
#
|
|
263
256
|
|
|
264
257
|
def double_click(element = nil, device: nil)
|
|
@@ -286,14 +279,11 @@ module Selenium
|
|
|
286
279
|
# @param [Selenium::WebDriver::Element] element An element to context click.
|
|
287
280
|
# @param [Symbol || String] device optional name of the PointerInput device with the button
|
|
288
281
|
# that will be context-clicked
|
|
289
|
-
# @return [
|
|
282
|
+
# @return [ActionBuilder] A self reference.
|
|
290
283
|
#
|
|
291
284
|
|
|
292
285
|
def context_click(element = nil, device: nil)
|
|
293
|
-
|
|
294
|
-
pointer_down(:right, device: device)
|
|
295
|
-
pointer_up(:right, device: device)
|
|
296
|
-
self
|
|
286
|
+
click(element, button: :right, device: device)
|
|
297
287
|
end
|
|
298
288
|
|
|
299
289
|
#
|
|
@@ -312,7 +302,7 @@ module Selenium
|
|
|
312
302
|
# mouse at.
|
|
313
303
|
# @param [Symbol || String] device optional name of the PointerInput device with the button
|
|
314
304
|
# that will perform the drag and drop
|
|
315
|
-
# @return [
|
|
305
|
+
# @return [ActionBuilder] A self reference.
|
|
316
306
|
#
|
|
317
307
|
|
|
318
308
|
def drag_and_drop(source, target, device: nil)
|
|
@@ -336,7 +326,7 @@ module Selenium
|
|
|
336
326
|
# @param [Integer] down_by vertical move offset.
|
|
337
327
|
# @param [Symbol || String] device optional name of the PointerInput device with the button
|
|
338
328
|
# that will perform the drag and drop
|
|
339
|
-
# @return [
|
|
329
|
+
# @return [ActionBuilder] A self reference.
|
|
340
330
|
#
|
|
341
331
|
|
|
342
332
|
def drag_and_drop_by(source, right_by, down_by, device: nil)
|
|
@@ -348,15 +338,15 @@ module Selenium
|
|
|
348
338
|
|
|
349
339
|
private
|
|
350
340
|
|
|
351
|
-
def button_action(button, action
|
|
352
|
-
pointer =
|
|
353
|
-
pointer.send(action, button)
|
|
341
|
+
def button_action(button, action, device: nil, **opts)
|
|
342
|
+
pointer = pointer_input(device)
|
|
343
|
+
pointer.send(action, button, **opts)
|
|
354
344
|
tick(pointer)
|
|
355
345
|
self
|
|
356
346
|
end
|
|
357
347
|
|
|
358
|
-
def
|
|
359
|
-
|
|
348
|
+
def pointer_input(name = nil)
|
|
349
|
+
device(name: name, type: Interactions::POINTER) || add_pointer_input(:mouse, 'mouse')
|
|
360
350
|
end
|
|
361
351
|
end # PointerActions
|
|
362
352
|
end # WebDriver
|
|
@@ -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
|
+
module Interactions
|
|
23
|
+
#
|
|
24
|
+
# Action to cancel any other Pointer Action.
|
|
25
|
+
#
|
|
26
|
+
# @api private
|
|
27
|
+
#
|
|
28
|
+
|
|
29
|
+
class PointerCancel < Interaction
|
|
30
|
+
def initialize(source)
|
|
31
|
+
super(source)
|
|
32
|
+
@type = :pointerCancel
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def assert_source(source)
|
|
36
|
+
raise TypeError, "#{source.type} is not a valid input type" unless source.is_a? PointerInput
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def encode
|
|
40
|
+
{type: type}
|
|
41
|
+
end
|
|
42
|
+
end # PointerCancel
|
|
43
|
+
end # Interactions
|
|
44
|
+
end # WebDriver
|
|
45
|
+
end # Selenium
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
module Interactions
|
|
23
|
+
module PointerEventProperties
|
|
24
|
+
VALID = {width: {'width' => {min: 0.0}},
|
|
25
|
+
height: {'height' => {min: 0.0}},
|
|
26
|
+
pressure: {'pressure' => {min: 0.0, max: 1.0}},
|
|
27
|
+
tangential_pressure: {'tangentialPressure' => {min: -1.0, max: 1.0}},
|
|
28
|
+
tilt_x: {'tiltX' => {min: -90, max: 90}},
|
|
29
|
+
tilt_y: {'tiltY' => {min: -90, max: 90}},
|
|
30
|
+
twist: {'twist' => {min: 0, max: 359}},
|
|
31
|
+
altitude_angle: {'altitudeAngle' => {min: 0.0, max: (Math::PI / 2)}},
|
|
32
|
+
azimuth_angle: {'azimuthAngle' => {min: 0.0, max: (Math::PI * 2)}}}.freeze
|
|
33
|
+
|
|
34
|
+
def process_opts
|
|
35
|
+
raise ArgumentError, "Unknown options found: #{@opts.inspect}" unless (@opts.keys - VALID.keys).empty?
|
|
36
|
+
|
|
37
|
+
VALID.each_with_object({}) do |(key, val), hash|
|
|
38
|
+
next unless @opts.key?(key)
|
|
39
|
+
|
|
40
|
+
name = val.keys.first
|
|
41
|
+
values = val.values.first
|
|
42
|
+
hash[name] = assert_number(@opts[key], values[:min], values[:max])
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def assert_number(num, min, max = nil)
|
|
49
|
+
return if num.nil?
|
|
50
|
+
|
|
51
|
+
klass = min.is_a?(Integer) ? Integer : Numeric
|
|
52
|
+
raise TypeError, "#{num} is not a #{klass}" unless num.is_a?(klass)
|
|
53
|
+
|
|
54
|
+
raise ArgumentError, "#{num} is not greater than or equal to #{min}" if num < min
|
|
55
|
+
|
|
56
|
+
raise ArgumentError, "#{num} is not less than or equal to #{max}" if max && num > max
|
|
57
|
+
|
|
58
|
+
num
|
|
59
|
+
end
|
|
60
|
+
end # PointerEventProperties
|
|
61
|
+
end # Interactions
|
|
62
|
+
end # WebDriver
|
|
63
|
+
end # Selenium
|