selenium-webdriver 4.1.0 → 4.28.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 +4 -4
- data/CHANGES +446 -1
- data/Gemfile +4 -0
- data/LICENSE +1 -1
- data/NOTICE +1 -1
- data/README.md +3 -3
- data/bin/linux/selenium-manager +0 -0
- data/bin/macos/selenium-manager +0 -0
- data/bin/windows/selenium-manager.exe +0 -0
- data/lib/selenium/server.rb +41 -43
- data/lib/selenium/webdriver/atoms/findElements.js +52 -50
- data/lib/selenium/webdriver/atoms/getAttribute.js +6 -100
- data/lib/selenium/webdriver/atoms/isDisplayed.js +24 -96
- data/lib/selenium/webdriver/atoms/mutationListener.js +0 -0
- data/lib/selenium/webdriver/atoms.rb +5 -3
- data/lib/selenium/webdriver/bidi/browsing_context.rb +100 -0
- data/lib/selenium/webdriver/bidi/log/base_log_entry.rb +35 -0
- data/lib/selenium/webdriver/bidi/log/console_log_entry.rb +35 -0
- data/lib/selenium/webdriver/{common/driver_extensions/has_location.rb → bidi/log/filter_by.rb} +14 -11
- data/lib/selenium/webdriver/bidi/log/generic_log_entry.rb +33 -0
- data/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb +33 -0
- data/lib/selenium/webdriver/bidi/log_handler.rb +65 -0
- data/lib/selenium/webdriver/bidi/log_inspector.rb +147 -0
- data/lib/selenium/webdriver/bidi/network.rb +82 -0
- data/lib/selenium/webdriver/bidi/session.rb +51 -0
- data/lib/selenium/webdriver/bidi/struct.rb +42 -0
- data/lib/selenium/webdriver/bidi.rb +67 -0
- data/lib/selenium/webdriver/chrome/driver.rb +9 -29
- data/lib/selenium/webdriver/chrome/features.rb +9 -67
- data/lib/selenium/webdriver/chrome/options.rb +3 -223
- data/lib/selenium/webdriver/chrome/profile.rb +3 -83
- data/lib/selenium/webdriver/chrome/service.rb +5 -19
- data/lib/selenium/webdriver/chrome.rb +0 -16
- data/lib/selenium/webdriver/chromium/driver.rb +61 -0
- data/lib/selenium/webdriver/chromium/features.rb +99 -0
- data/lib/selenium/webdriver/chromium/options.rb +243 -0
- data/lib/selenium/webdriver/chromium/profile.rb +113 -0
- data/lib/selenium/webdriver/chromium.rb +29 -0
- data/lib/selenium/webdriver/common/action_builder.rb +60 -22
- data/lib/selenium/webdriver/common/child_process.rb +136 -0
- data/lib/selenium/webdriver/common/driver.rb +54 -89
- data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +0 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/{has_remote_status.rb → has_bidi.rb} +10 -5
- data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +10 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +1 -4
- data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_fedcm_dialog.rb +55 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_file_downloads.rb +65 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +9 -3
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +8 -68
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +1 -3
- data/lib/selenium/webdriver/common/driver_finder.rb +97 -0
- data/lib/selenium/webdriver/common/element.rb +8 -8
- data/lib/selenium/webdriver/common/error.rb +29 -4
- data/lib/selenium/webdriver/common/fedcm/account.rb +49 -0
- data/lib/selenium/webdriver/common/fedcm/dialog.rb +74 -0
- data/lib/selenium/webdriver/common/fedcm.rb +27 -0
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +2 -2
- data/lib/selenium/webdriver/common/interactions/input_device.rb +10 -4
- data/lib/selenium/webdriver/common/interactions/interaction.rb +12 -25
- data/lib/selenium/webdriver/common/interactions/interactions.rb +24 -4
- data/lib/selenium/webdriver/common/interactions/key_actions.rb +5 -1
- 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 +59 -71
- data/lib/selenium/webdriver/common/{driver_extensions/has_network_connection.rb → interactions/pointer_cancel.rb} +19 -11
- 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 +59 -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 +114 -0
- data/lib/selenium/webdriver/common/interactions/wheel_input.rb +42 -0
- data/lib/selenium/webdriver/common/keys.rb +1 -0
- data/lib/selenium/webdriver/common/local_driver.rb +53 -0
- data/lib/selenium/webdriver/common/logger.rb +93 -28
- data/lib/selenium/webdriver/common/manager.rb +2 -29
- data/lib/selenium/webdriver/common/network.rb +64 -0
- data/lib/selenium/webdriver/common/options.rb +19 -19
- data/lib/selenium/webdriver/common/platform.rb +12 -52
- data/lib/selenium/webdriver/common/port_prober.rb +1 -1
- data/lib/selenium/webdriver/common/profile_helper.rb +1 -1
- data/lib/selenium/webdriver/common/proxy.rb +4 -4
- data/lib/selenium/webdriver/common/script.rb +45 -0
- data/lib/selenium/webdriver/common/search_context.rb +10 -8
- data/lib/selenium/webdriver/common/selenium_manager.rb +104 -0
- data/lib/selenium/webdriver/common/service.rb +24 -26
- data/lib/selenium/webdriver/common/service_manager.rb +9 -15
- data/lib/selenium/webdriver/common/shadow_root.rb +2 -3
- data/lib/selenium/webdriver/common/socket_lock.rb +3 -3
- data/lib/selenium/webdriver/common/socket_poller.rb +3 -3
- data/lib/selenium/webdriver/common/takes_screenshot.rb +6 -5
- data/lib/selenium/webdriver/common/target_locator.rb +5 -5
- data/lib/selenium/webdriver/common/timeouts.rb +2 -2
- data/lib/selenium/webdriver/common/virtual_authenticator/credential.rb +85 -0
- data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator.rb +72 -0
- data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator_options.rb +62 -0
- data/lib/selenium/webdriver/common/wait.rb +1 -1
- data/lib/selenium/webdriver/common/websocket_connection.rb +176 -0
- data/lib/selenium/webdriver/common/window.rb +6 -6
- data/lib/selenium/webdriver/common/zipper.rb +1 -1
- data/lib/selenium/webdriver/common.rb +27 -5
- data/lib/selenium/webdriver/devtools/console_event.rb +0 -2
- data/lib/selenium/webdriver/devtools/exception_event.rb +0 -2
- data/lib/selenium/webdriver/devtools/mutation_event.rb +0 -2
- data/lib/selenium/webdriver/devtools/network_interceptor.rb +173 -0
- data/lib/selenium/webdriver/devtools/pinned_script.rb +0 -2
- data/lib/selenium/webdriver/devtools/request.rb +1 -3
- data/lib/selenium/webdriver/devtools/response.rb +1 -3
- data/lib/selenium/webdriver/devtools.rb +17 -114
- data/lib/selenium/webdriver/edge/driver.rb +9 -3
- data/lib/selenium/webdriver/edge/features.rb +8 -4
- data/lib/selenium/webdriver/edge/options.rb +17 -5
- data/lib/selenium/webdriver/edge/profile.rb +2 -2
- data/lib/selenium/webdriver/edge/service.rb +8 -7
- data/lib/selenium/webdriver/edge.rb +0 -2
- data/lib/selenium/webdriver/firefox/driver.rb +9 -2
- data/lib/selenium/webdriver/firefox/features.rb +11 -7
- data/lib/selenium/webdriver/firefox/options.rb +10 -16
- data/lib/selenium/webdriver/firefox/profile.rb +21 -17
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +1 -1
- data/lib/selenium/webdriver/firefox/service.rb +1 -18
- data/lib/selenium/webdriver/firefox/util.rb +46 -0
- data/lib/selenium/webdriver/firefox.rb +1 -14
- data/lib/selenium/webdriver/ie/driver.rb +7 -1
- data/lib/selenium/webdriver/ie/features.rb +34 -0
- data/lib/selenium/webdriver/ie/options.rb +6 -4
- data/lib/selenium/webdriver/ie/service.rb +1 -22
- data/lib/selenium/webdriver/ie.rb +4 -17
- data/lib/selenium/webdriver/remote/bidi_bridge.rb +66 -0
- data/lib/selenium/webdriver/remote/{commands.rb → bridge/commands.rb} +22 -9
- data/lib/selenium/webdriver/remote/bridge/locator_converter.rb +76 -0
- data/lib/selenium/webdriver/remote/bridge.rb +158 -100
- data/lib/selenium/webdriver/remote/capabilities.rb +5 -55
- data/lib/selenium/webdriver/remote/driver.rb +35 -14
- data/lib/selenium/webdriver/remote/features.rb +75 -0
- data/lib/selenium/webdriver/remote/http/common.rb +26 -6
- data/lib/selenium/webdriver/remote/http/curb.rb +10 -6
- data/lib/selenium/webdriver/remote/http/default.rb +8 -14
- data/lib/selenium/webdriver/remote/response.rb +14 -22
- data/lib/selenium/webdriver/remote/server_error.rb +2 -2
- data/lib/selenium/webdriver/remote.rb +3 -2
- data/lib/selenium/webdriver/safari/driver.rb +7 -1
- data/lib/selenium/webdriver/safari/features.rb +5 -3
- data/lib/selenium/webdriver/safari/options.rb +5 -1
- data/lib/selenium/webdriver/safari/service.rb +10 -4
- data/lib/selenium/webdriver/safari.rb +1 -15
- data/lib/selenium/webdriver/support/color.rb +22 -22
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +4 -4
- data/lib/selenium/webdriver/support/guards/guard.rb +14 -14
- data/lib/selenium/webdriver/support/guards/guard_condition.rb +1 -3
- data/lib/selenium/webdriver/support/guards.rb +4 -4
- data/lib/selenium/webdriver/support/relative_locator.rb +0 -1
- data/lib/selenium/webdriver/support/select.rb +3 -1
- data/lib/selenium/webdriver/version.rb +1 -1
- data/lib/selenium/webdriver.rb +7 -5
- data/selenium-webdriver.gemspec +22 -16
- metadata +137 -47
- data/lib/selenium/webdriver/remote/http/persistent.rb +0 -65
- data/lib/selenium/webdriver/support/cdp/domain.rb.erb +0 -63
- data/lib/selenium/webdriver/support/cdp_client_generator.rb +0 -108
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
# Actions related to clicking, tapping or pressing the pointer.
|
|
25
|
+
#
|
|
26
|
+
# @api private
|
|
27
|
+
#
|
|
28
|
+
|
|
29
|
+
class PointerPress < Interaction
|
|
30
|
+
include PointerEventProperties
|
|
31
|
+
|
|
32
|
+
BUTTONS = {left: 0,
|
|
33
|
+
touch: 0,
|
|
34
|
+
pen_contact: 0,
|
|
35
|
+
middle: 1,
|
|
36
|
+
right: 2,
|
|
37
|
+
pen_barrel: 2,
|
|
38
|
+
x1: 3,
|
|
39
|
+
back: 3,
|
|
40
|
+
x2: 4,
|
|
41
|
+
forward: 4}.freeze
|
|
42
|
+
DIRECTIONS = {down: :pointerDown, up: :pointerUp}.freeze
|
|
43
|
+
|
|
44
|
+
def initialize(source, direction, button, **opts)
|
|
45
|
+
super(source)
|
|
46
|
+
@direction = assert_direction(direction)
|
|
47
|
+
@button = assert_button(button)
|
|
48
|
+
@type = @direction
|
|
49
|
+
@opts = opts
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def encode
|
|
53
|
+
process_opts.merge('type' => type.to_s, 'button' => @button)
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
|
|
58
|
+
def assert_source(source)
|
|
59
|
+
raise TypeError, "#{source.type} is not a valid input type" unless source.is_a? PointerInput
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def assert_button(button)
|
|
63
|
+
case button
|
|
64
|
+
when Symbol
|
|
65
|
+
raise ArgumentError, "#{button} is not a valid button!" unless BUTTONS.key? button
|
|
66
|
+
|
|
67
|
+
BUTTONS[button]
|
|
68
|
+
when Integer
|
|
69
|
+
raise ArgumentError, 'Button number cannot be negative!' if button.negative?
|
|
70
|
+
|
|
71
|
+
button
|
|
72
|
+
else
|
|
73
|
+
raise TypeError, "button must be a positive integer or one of #{BUTTONS.keys}, not #{button.class}"
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def assert_direction(direction)
|
|
78
|
+
raise ArgumentError, "#{direction.inspect} is not a valid button direction" unless DIRECTIONS.key? direction
|
|
79
|
+
|
|
80
|
+
DIRECTIONS[direction]
|
|
81
|
+
end
|
|
82
|
+
end # PointerPress
|
|
83
|
+
end # Interactions
|
|
84
|
+
end # WebDriver
|
|
85
|
+
end # Selenium
|
|
@@ -0,0 +1,59 @@
|
|
|
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 related to scrolling a wheel.
|
|
25
|
+
#
|
|
26
|
+
# @api private
|
|
27
|
+
#
|
|
28
|
+
|
|
29
|
+
class Scroll < Interaction
|
|
30
|
+
def initialize(source:, origin: :viewport, duration: 0.25, **opts)
|
|
31
|
+
super(source)
|
|
32
|
+
@type = :scroll
|
|
33
|
+
@duration = duration * 1000
|
|
34
|
+
@origin = origin
|
|
35
|
+
@x_offset = opts.delete(:x) || 0
|
|
36
|
+
@y_offset = opts.delete(:y) || 0
|
|
37
|
+
@delta_x = opts.delete(:delta_x) || 0
|
|
38
|
+
@delta_y = opts.delete(:delta_y) || 0
|
|
39
|
+
|
|
40
|
+
raise ArgumentError, "Invalid arguments: #{opts.keys}" unless opts.empty?
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def assert_source(source)
|
|
44
|
+
raise TypeError, "#{source.type} is not a valid input type" unless source.is_a? WheelInput
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def encode
|
|
48
|
+
{'type' => type.to_s,
|
|
49
|
+
'duration' => @duration.to_i,
|
|
50
|
+
'x' => @x_offset,
|
|
51
|
+
'y' => @y_offset,
|
|
52
|
+
'deltaX' => @delta_x,
|
|
53
|
+
'deltaY' => @delta_y,
|
|
54
|
+
'origin' => @origin.is_a?(Element) ? @origin : @origin.to_s}
|
|
55
|
+
end
|
|
56
|
+
end # PointerPress
|
|
57
|
+
end # Interactions
|
|
58
|
+
end # WebDriver
|
|
59
|
+
end # Selenium
|
|
@@ -0,0 +1,48 @@
|
|
|
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 WheelActions
|
|
23
|
+
class ScrollOrigin
|
|
24
|
+
class << self
|
|
25
|
+
def element(element, x_offset = 0, y_offset = 0)
|
|
26
|
+
new(element, x_offset, y_offset)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def viewport(x_offset = 0, y_offset = 0)
|
|
30
|
+
new(:viewport, x_offset, y_offset)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
attr_reader :origin, :x_offset, :y_offset
|
|
35
|
+
|
|
36
|
+
#
|
|
37
|
+
# Use a static method to access
|
|
38
|
+
# @api private
|
|
39
|
+
#
|
|
40
|
+
def initialize(origin, x_offset, y_offset)
|
|
41
|
+
@origin = origin
|
|
42
|
+
@x_offset = x_offset
|
|
43
|
+
@y_offset = y_offset
|
|
44
|
+
end
|
|
45
|
+
end # ScrollOrigin
|
|
46
|
+
end # WheelActions
|
|
47
|
+
end # WebDriver
|
|
48
|
+
end # Selenium
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
# Actions related to pressing keys.
|
|
25
|
+
#
|
|
26
|
+
# @api private
|
|
27
|
+
#
|
|
28
|
+
|
|
29
|
+
class TypingInteraction < Interaction
|
|
30
|
+
attr_reader :type
|
|
31
|
+
|
|
32
|
+
def initialize(source, type, key)
|
|
33
|
+
super(source)
|
|
34
|
+
@type = assert_type(type)
|
|
35
|
+
@key = Keys.encode_key(key)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def assert_source(source)
|
|
39
|
+
raise TypeError, "#{source.type} is not a valid input type" unless source.is_a? KeyInput
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def assert_type(type)
|
|
43
|
+
raise TypeError, "#{type.inspect} is not a valid key subtype" unless KeyInput::SUBTYPES.key? type
|
|
44
|
+
|
|
45
|
+
KeyInput::SUBTYPES[type]
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def encode
|
|
49
|
+
{type: @type, value: @key}
|
|
50
|
+
end
|
|
51
|
+
end # TypingInteraction
|
|
52
|
+
end # Interactions
|
|
53
|
+
end # WebDriver
|
|
54
|
+
end # Selenium
|
|
@@ -0,0 +1,114 @@
|
|
|
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 WheelActions
|
|
23
|
+
attr_writer :default_scroll_duration
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# By default this is set to 250ms in the ActionBuilder constructor
|
|
27
|
+
# It can be overridden with default_scroll_duration=
|
|
28
|
+
#
|
|
29
|
+
|
|
30
|
+
def default_scroll_duration
|
|
31
|
+
@default_scroll_duration ||= @duration / 1000.0 # convert ms to seconds
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
#
|
|
35
|
+
# If the element is outside the viewport, scrolls the bottom of the element to the bottom of the viewport.
|
|
36
|
+
#
|
|
37
|
+
# @example Scroll to element
|
|
38
|
+
# el = driver.find_element(id: "some_id")
|
|
39
|
+
# driver.action.scroll_to(element).perform
|
|
40
|
+
#
|
|
41
|
+
# @param [Object] element Which element to scroll into the viewport.
|
|
42
|
+
# @param [Object] device Which device to use to scroll
|
|
43
|
+
# @return [Selenium::WebDriver::WheelActions] A self reference.
|
|
44
|
+
def scroll_to(element, device: nil)
|
|
45
|
+
scroll(origin: element, device: device)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
#
|
|
49
|
+
# Scrolls by provided amounts with the origin in the top left corner of the viewport.
|
|
50
|
+
#
|
|
51
|
+
# @example Scroll viewport by a specified amount
|
|
52
|
+
# el = driver.find_element(id: "some_id")
|
|
53
|
+
# driver.action.scroll_by(100, 200).perform
|
|
54
|
+
#
|
|
55
|
+
# @param [Integer] delta_x Distance along X axis to scroll using the wheel. A negative value scrolls left.
|
|
56
|
+
# @param [Integer] delta_y Distance along Y axis to scroll using the wheel. A negative value scrolls up.
|
|
57
|
+
# @return [Selenium::WebDriver::WheelActions] A self reference.
|
|
58
|
+
def scroll_by(delta_x, delta_y, device: nil)
|
|
59
|
+
scroll(delta_x: delta_x, delta_y: delta_y, device: device)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
#
|
|
63
|
+
# Scrolls by provided amount based on a provided origin.
|
|
64
|
+
#
|
|
65
|
+
# The scroll origin is either the center of an element or the upper left of the viewport plus any offsets.
|
|
66
|
+
# If the origin is an element, and the element is not in the viewport, the bottom of the element will first
|
|
67
|
+
# be scrolled to the bottom of the viewport.
|
|
68
|
+
#
|
|
69
|
+
# @example Scroll from element by a specified amount
|
|
70
|
+
# el = driver.find_element(id: "some_id")
|
|
71
|
+
# origin = WheelActions::ScrollOrigin.element(el)
|
|
72
|
+
# driver.action.scroll_from(origin, 0, 200).perform
|
|
73
|
+
#
|
|
74
|
+
# @example Scroll from element by a specified amount with an offset
|
|
75
|
+
# el = driver.find_element(id: "some_id")
|
|
76
|
+
# origin = WheelActions::ScrollOrigin.element(el, 10, 10)
|
|
77
|
+
# driver.action.scroll_from(origin, 100, 200).perform
|
|
78
|
+
#
|
|
79
|
+
# @example Scroll viewport by a specified amount with an offset
|
|
80
|
+
# origin = WheelActions::ScrollOrigin.viewport(10, 10)
|
|
81
|
+
# driver.action.scroll_from(origin, 0, 200).perform
|
|
82
|
+
#
|
|
83
|
+
# @param [ScrollOrigin] scroll_origin Where scroll originates (viewport or element center) plus provided offsets.
|
|
84
|
+
# @param [Integer] delta_x Distance along X axis to scroll using the wheel. A negative value scrolls left.
|
|
85
|
+
# @param [Integer] delta_y Distance along Y axis to scroll using the wheel. A negative value scrolls up.
|
|
86
|
+
# @return [Selenium::WebDriver::WheelActions] A self reference.
|
|
87
|
+
# @raise [Error::MoveTargetOutOfBoundsError] If the origin with offset is outside the viewport.
|
|
88
|
+
def scroll_from(scroll_origin, delta_x, delta_y, device: nil)
|
|
89
|
+
raise TypeError, "#{scroll_origin.inspect} isn't a valid ScrollOrigin" unless scroll_origin.is_a?(ScrollOrigin)
|
|
90
|
+
|
|
91
|
+
scroll(x: scroll_origin.x_offset,
|
|
92
|
+
y: scroll_origin.y_offset,
|
|
93
|
+
delta_x: delta_x,
|
|
94
|
+
delta_y: delta_y,
|
|
95
|
+
origin: scroll_origin.origin,
|
|
96
|
+
device: device)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
private
|
|
100
|
+
|
|
101
|
+
def scroll(**opts)
|
|
102
|
+
opts[:duration] = default_scroll_duration
|
|
103
|
+
wheel = wheel_input(opts.delete(:device))
|
|
104
|
+
wheel.create_scroll(**opts)
|
|
105
|
+
tick(wheel)
|
|
106
|
+
self
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def wheel_input(name = nil)
|
|
110
|
+
device(name: name, type: Interactions::WHEEL) || add_wheel_input('wheel')
|
|
111
|
+
end
|
|
112
|
+
end # WheelActions
|
|
113
|
+
end # WebDriver
|
|
114
|
+
end # Selenium
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
# Creates actions specific to Pointer Input devices
|
|
25
|
+
#
|
|
26
|
+
# @api private
|
|
27
|
+
#
|
|
28
|
+
|
|
29
|
+
class WheelInput < InputDevice
|
|
30
|
+
def initialize(name = nil)
|
|
31
|
+
super
|
|
32
|
+
@type = Interactions::WHEEL
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def create_scroll(**opts)
|
|
36
|
+
opts[:source] = self
|
|
37
|
+
add_action(Scroll.new(**opts))
|
|
38
|
+
end
|
|
39
|
+
end # PointerInput
|
|
40
|
+
end # Interactions
|
|
41
|
+
end # WebDriver
|
|
42
|
+
end # Selenium
|
|
@@ -0,0 +1,53 @@
|
|
|
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 LocalDriver
|
|
23
|
+
def initialize_local_driver(options, service, url)
|
|
24
|
+
raise ArgumentError, "Can't initialize #{self.class} with :url" if url
|
|
25
|
+
|
|
26
|
+
service ||= Service.send(browser)
|
|
27
|
+
caps = process_options(options, service)
|
|
28
|
+
url = service_url(service)
|
|
29
|
+
|
|
30
|
+
[caps, url]
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def process_options(options, service)
|
|
34
|
+
default_options = Options.send(browser)
|
|
35
|
+
options ||= default_options
|
|
36
|
+
|
|
37
|
+
unless options.is_a?(default_options.class)
|
|
38
|
+
raise ArgumentError, ":options must be an instance of #{default_options.class}"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
service.executable_path ||= begin
|
|
42
|
+
finder = WebDriver::DriverFinder.new(options, service)
|
|
43
|
+
if options.respond_to?(:binary) && finder.browser_path?
|
|
44
|
+
options.binary = finder.browser_path
|
|
45
|
+
options.browser_version = nil
|
|
46
|
+
end
|
|
47
|
+
finder.driver_path
|
|
48
|
+
end
|
|
49
|
+
options.as_json
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -38,19 +38,31 @@ module Selenium
|
|
|
38
38
|
|
|
39
39
|
def_delegators :@logger,
|
|
40
40
|
:close,
|
|
41
|
-
:debug
|
|
42
|
-
:info
|
|
41
|
+
:debug?,
|
|
42
|
+
:info?,
|
|
43
43
|
:warn?,
|
|
44
|
-
:error
|
|
44
|
+
:error?,
|
|
45
45
|
:fatal, :fatal?,
|
|
46
|
-
:level
|
|
46
|
+
:level
|
|
47
47
|
|
|
48
48
|
#
|
|
49
49
|
# @param [String] progname Allow child projects to use Selenium's Logger pattern
|
|
50
50
|
#
|
|
51
|
-
def initialize(progname = 'Selenium')
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
def initialize(progname = 'Selenium', default_level: nil, ignored: nil, allowed: nil)
|
|
52
|
+
default_level ||= $DEBUG || ENV.key?('DEBUG') ? :debug : :warn
|
|
53
|
+
|
|
54
|
+
@logger = create_logger(progname, level: default_level)
|
|
55
|
+
@ignored = Array(ignored)
|
|
56
|
+
@allowed = Array(allowed)
|
|
57
|
+
@first_warning = false
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def level=(level)
|
|
61
|
+
if level == :info && @logger.level == :info
|
|
62
|
+
info(':info is now the default log level, to see additional logging, set log level to :debug')
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
@logger.level = level
|
|
54
66
|
end
|
|
55
67
|
|
|
56
68
|
#
|
|
@@ -80,27 +92,64 @@ module Selenium
|
|
|
80
92
|
#
|
|
81
93
|
# Will not log the provided ID.
|
|
82
94
|
#
|
|
83
|
-
# @param [Array, Symbol]
|
|
95
|
+
# @param [Array, Symbol] ids
|
|
84
96
|
#
|
|
85
|
-
def ignore(
|
|
86
|
-
Array(
|
|
97
|
+
def ignore(*ids)
|
|
98
|
+
@ignored += Array(ids).flatten
|
|
87
99
|
end
|
|
88
100
|
|
|
89
101
|
#
|
|
90
|
-
#
|
|
102
|
+
# Will only log the provided ID.
|
|
103
|
+
#
|
|
104
|
+
# @param [Array, Symbol] ids
|
|
105
|
+
#
|
|
106
|
+
def allow(*ids)
|
|
107
|
+
@allowed += Array(ids).flatten
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
#
|
|
111
|
+
# Used to supply information of interest for debugging a problem
|
|
112
|
+
# Overrides default #debug to skip ignored messages by provided id
|
|
91
113
|
#
|
|
92
114
|
# @param [String] message
|
|
93
|
-
# @param [Symbol, Array<
|
|
115
|
+
# @param [Symbol, Array<Symbol>] id
|
|
94
116
|
# @yield see #deprecate
|
|
95
117
|
#
|
|
96
|
-
def
|
|
97
|
-
|
|
98
|
-
|
|
118
|
+
def debug(message, id: [], &block)
|
|
119
|
+
discard_or_log(:debug, message, id, &block)
|
|
120
|
+
end
|
|
99
121
|
|
|
100
|
-
|
|
101
|
-
|
|
122
|
+
#
|
|
123
|
+
# Used to supply information of general interest
|
|
124
|
+
#
|
|
125
|
+
# @param [String] message
|
|
126
|
+
# @param [Symbol, Array<Symbol>] id
|
|
127
|
+
# @yield see #deprecate
|
|
128
|
+
#
|
|
129
|
+
def info(message, id: [], &block)
|
|
130
|
+
discard_or_log(:info, message, id, &block)
|
|
131
|
+
end
|
|
102
132
|
|
|
103
|
-
|
|
133
|
+
#
|
|
134
|
+
# Used to supply information that suggests an error occurred
|
|
135
|
+
#
|
|
136
|
+
# @param [String] message
|
|
137
|
+
# @param [Symbol, Array<Symbol>] id
|
|
138
|
+
# @yield see #deprecate
|
|
139
|
+
#
|
|
140
|
+
def error(message, id: [], &block)
|
|
141
|
+
discard_or_log(:error, message, id, &block)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
#
|
|
145
|
+
# Used to supply information that suggests action be taken by user
|
|
146
|
+
#
|
|
147
|
+
# @param [String] message
|
|
148
|
+
# @param [Symbol, Array<Symbol>] id
|
|
149
|
+
# @yield see #deprecate
|
|
150
|
+
#
|
|
151
|
+
def warn(message, id: [], &block)
|
|
152
|
+
discard_or_log(:warn, message, id, &block)
|
|
104
153
|
end
|
|
105
154
|
|
|
106
155
|
#
|
|
@@ -114,11 +163,11 @@ module Selenium
|
|
|
114
163
|
#
|
|
115
164
|
def deprecate(old, new = nil, id: [], reference: '', &block)
|
|
116
165
|
id = Array(id)
|
|
117
|
-
return if @ignored.include?(:deprecations)
|
|
166
|
+
return if @ignored.include?(:deprecations)
|
|
118
167
|
|
|
119
|
-
|
|
168
|
+
id << :deprecations if @allowed.include?(:deprecations)
|
|
120
169
|
|
|
121
|
-
message =
|
|
170
|
+
message = "[DEPRECATION] #{old} is deprecated"
|
|
122
171
|
message << if new
|
|
123
172
|
". Use #{new} instead."
|
|
124
173
|
else
|
|
@@ -126,24 +175,40 @@ module Selenium
|
|
|
126
175
|
end
|
|
127
176
|
message << " See explanation for this deprecation: #{reference}." unless reference.empty?
|
|
128
177
|
|
|
129
|
-
warn message, &block
|
|
178
|
+
discard_or_log(:warn, message, id, &block)
|
|
130
179
|
end
|
|
131
180
|
|
|
132
181
|
private
|
|
133
182
|
|
|
134
|
-
def create_logger(name)
|
|
135
|
-
logger = ::Logger.new($
|
|
183
|
+
def create_logger(name, level:)
|
|
184
|
+
logger = ::Logger.new($stderr)
|
|
136
185
|
logger.progname = name
|
|
137
|
-
logger.level =
|
|
186
|
+
logger.level = level
|
|
138
187
|
logger.formatter = proc do |severity, time, progname, msg|
|
|
139
|
-
"#{time.strftime('%F %T')} #{severity} #{progname} #{msg}\n"
|
|
188
|
+
"#{time.strftime('%F %T')} #{severity} #{progname} #{msg}\n".force_encoding('UTF-8')
|
|
140
189
|
end
|
|
141
190
|
|
|
142
191
|
logger
|
|
143
192
|
end
|
|
144
193
|
|
|
145
|
-
def
|
|
146
|
-
|
|
194
|
+
def discard_or_log(level, message, id)
|
|
195
|
+
id = Array(id)
|
|
196
|
+
return if @ignored.intersect?(id)
|
|
197
|
+
return if @allowed.any? && !@allowed.intersect?(id)
|
|
198
|
+
|
|
199
|
+
return if ::Logger::Severity.const_get(level.upcase) < @logger.level
|
|
200
|
+
|
|
201
|
+
unless @first_warning
|
|
202
|
+
@first_warning = true
|
|
203
|
+
info("Details on how to use and modify Selenium logger:\n", id: [:logger_info]) do
|
|
204
|
+
"https://selenium.dev/documentation/webdriver/troubleshooting/logging\n"
|
|
205
|
+
end
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
msg = id.empty? ? message : "[#{id.map(&:inspect).join(', ')}] #{message} "
|
|
209
|
+
msg += " #{yield}" if block_given?
|
|
210
|
+
|
|
211
|
+
@logger.send(level) { msg }
|
|
147
212
|
end
|
|
148
213
|
end # Logger
|
|
149
214
|
end # WebDriver
|