selenium-webdriver 3.142.7 → 4.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES +685 -5
- data/Gemfile +6 -1
- data/LICENSE +1 -1
- data/NOTICE +2 -0
- data/README.md +4 -5
- 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 +93 -90
- 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 +77 -78
- data/lib/selenium/webdriver/atoms/mutationListener.js +55 -0
- data/lib/selenium/webdriver/atoms.rb +5 -3
- data/lib/selenium/webdriver/bidi/browsing_context.rb +88 -0
- data/lib/selenium/webdriver/bidi/browsing_context_info.rb +35 -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/bidi/log/filter_by.rb +40 -0
- 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_inspector.rb +143 -0
- data/lib/selenium/webdriver/bidi/navigate_result.rb +33 -0
- data/lib/selenium/webdriver/bidi/session.rb +51 -0
- data/lib/selenium/webdriver/{common/keyboard.rb → bidi.rb} +21 -35
- data/lib/selenium/webdriver/chrome/driver.rb +9 -86
- data/lib/selenium/webdriver/chrome/features.rb +48 -0
- data/lib/selenium/webdriver/chrome/options.rb +9 -158
- data/lib/selenium/webdriver/chrome/profile.rb +3 -80
- data/lib/selenium/webdriver/chrome/service.rb +7 -29
- data/lib/selenium/webdriver/chrome.rb +5 -20
- data/lib/selenium/webdriver/chromium/driver.rb +60 -0
- data/lib/selenium/webdriver/{chrome/bridge.rb → chromium/features.rb} +48 -17
- 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 +126 -238
- data/lib/selenium/webdriver/common/child_process.rb +124 -0
- data/lib/selenium/webdriver/common/driver.rb +82 -43
- data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/{has_location.rb → full_page_screenshot.rb} +13 -11
- data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +49 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +87 -0
- data/lib/selenium/webdriver/common/driver_extensions/{has_touch_screen.rb → has_bidi.rb} +9 -9
- data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +86 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +36 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +42 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +41 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_file_downloads.rb +65 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +36 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +143 -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 +16 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +69 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +11 -13
- data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +75 -0
- data/lib/selenium/webdriver/common/driver_extensions/{rotatable.rb → prints_page.rb} +18 -20
- data/lib/selenium/webdriver/common/driver_finder.rb +45 -0
- data/lib/selenium/webdriver/common/element.rb +89 -29
- data/lib/selenium/webdriver/common/error.rb +53 -194
- 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 -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 +71 -82
- 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 +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 +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/local_driver.rb +46 -0
- data/lib/selenium/webdriver/common/log_entry.rb +2 -2
- data/lib/selenium/webdriver/common/logger.rb +119 -19
- data/lib/selenium/webdriver/common/manager.rb +11 -38
- data/lib/selenium/webdriver/common/options.rb +154 -23
- data/lib/selenium/webdriver/common/platform.rb +15 -52
- 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 +8 -5
- data/lib/selenium/webdriver/common/search_context.rb +7 -9
- data/lib/selenium/webdriver/common/selenium_manager.rb +140 -0
- data/lib/selenium/webdriver/common/service.rb +26 -143
- data/lib/selenium/webdriver/common/service_manager.rb +144 -0
- data/lib/selenium/webdriver/common/shadow_root.rb +86 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +4 -4
- data/lib/selenium/webdriver/common/socket_poller.rb +4 -4
- data/lib/selenium/webdriver/common/takes_screenshot.rb +65 -0
- data/lib/selenium/webdriver/common/target_locator.rb +31 -4
- data/lib/selenium/webdriver/common/timeouts.rb +31 -4
- 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 +164 -0
- data/lib/selenium/webdriver/common/window.rb +6 -10
- data/lib/selenium/webdriver/common/zipper.rb +4 -10
- data/lib/selenium/webdriver/common.rb +43 -20
- data/lib/selenium/webdriver/devtools/console_event.rb +36 -0
- data/lib/selenium/webdriver/devtools/exception_event.rb +34 -0
- data/lib/selenium/webdriver/devtools/mutation_event.rb +35 -0
- data/lib/selenium/webdriver/devtools/network_interceptor.rb +173 -0
- data/lib/selenium/webdriver/devtools/pinned_script.rb +57 -0
- data/lib/selenium/webdriver/devtools/request.rb +65 -0
- data/lib/selenium/webdriver/devtools/response.rb +64 -0
- data/lib/selenium/webdriver/devtools.rb +96 -0
- data/lib/selenium/webdriver/edge/driver.rb +11 -27
- data/lib/selenium/webdriver/edge/features.rb +48 -0
- data/lib/selenium/webdriver/edge/options.rb +18 -43
- data/lib/selenium/webdriver/edge/profile.rb +33 -0
- data/lib/selenium/webdriver/edge/service.rb +8 -23
- data/lib/selenium/webdriver/edge.rb +11 -16
- data/lib/selenium/webdriver/firefox/driver.rb +38 -19
- data/lib/selenium/webdriver/firefox/extension.rb +8 -0
- data/lib/selenium/webdriver/firefox/features.rb +70 -0
- data/lib/selenium/webdriver/firefox/options.rb +73 -61
- data/lib/selenium/webdriver/firefox/profile.rb +20 -72
- data/lib/selenium/webdriver/firefox/service.rb +3 -25
- data/lib/selenium/webdriver/firefox/util.rb +1 -1
- data/lib/selenium/webdriver/firefox.rb +17 -28
- data/lib/selenium/webdriver/ie/driver.rb +5 -45
- data/lib/selenium/webdriver/ie/features.rb +34 -0
- data/lib/selenium/webdriver/ie/options.rb +14 -44
- data/lib/selenium/webdriver/ie/service.rb +3 -27
- data/lib/selenium/webdriver/ie.rb +4 -16
- data/lib/selenium/webdriver/remote/bridge/commands.rb +164 -0
- data/lib/selenium/webdriver/remote/bridge.rb +574 -88
- data/lib/selenium/webdriver/remote/capabilities.rb +144 -158
- data/lib/selenium/webdriver/remote/driver.rb +45 -14
- data/lib/selenium/webdriver/remote/features.rb +75 -0
- data/lib/selenium/webdriver/remote/http/common.rb +3 -8
- data/lib/selenium/webdriver/remote/http/curb.rb +1 -3
- data/lib/selenium/webdriver/remote/http/default.rb +24 -33
- data/lib/selenium/webdriver/remote/response.rb +17 -49
- data/lib/selenium/webdriver/remote/server_error.rb +1 -1
- data/lib/selenium/webdriver/remote.rb +15 -12
- data/lib/selenium/webdriver/safari/driver.rb +7 -29
- data/lib/selenium/webdriver/safari/{bridge.rb → features.rb} +7 -5
- data/lib/selenium/webdriver/safari/options.rb +12 -27
- data/lib/selenium/webdriver/safari/service.rb +13 -11
- data/lib/selenium/webdriver/safari.rb +14 -20
- data/lib/selenium/webdriver/support/block_event_listener.rb +1 -1
- data/lib/selenium/webdriver/support/color.rb +24 -24
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +5 -5
- data/lib/selenium/webdriver/support/guards/guard.rb +90 -0
- data/lib/selenium/webdriver/{firefox/marionette/bridge.rb → support/guards/guard_condition.rb} +21 -20
- data/lib/selenium/webdriver/support/guards.rb +95 -0
- data/lib/selenium/webdriver/support/relative_locator.rb +50 -0
- data/lib/selenium/webdriver/support/select.rb +6 -4
- data/lib/selenium/webdriver/support.rb +1 -0
- data/lib/selenium/webdriver/version.rb +1 -1
- data/lib/selenium/webdriver.rb +19 -17
- data/selenium-webdriver.gemspec +36 -18
- metadata +161 -91
- data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +0 -58
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +0 -64
- 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
@@ -0,0 +1,90 @@
|
|
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 Support
|
23
|
+
class Guards
|
24
|
+
#
|
25
|
+
# Guard derived from RSpec example metadata.
|
26
|
+
# @api private
|
27
|
+
#
|
28
|
+
|
29
|
+
class Guard
|
30
|
+
attr_reader :guarded, :type, :messages, :reason
|
31
|
+
|
32
|
+
def initialize(guarded, type, guards = nil)
|
33
|
+
@guarded = guarded
|
34
|
+
@tracker = guards&.bug_tracker || ''
|
35
|
+
@messages = guards&.messages || {}
|
36
|
+
@messages[:unknown] = 'TODO: Investigate why this is failing and file a bug report'
|
37
|
+
@type = type
|
38
|
+
|
39
|
+
@reason = @guarded.delete(:reason)
|
40
|
+
end
|
41
|
+
|
42
|
+
def message
|
43
|
+
details = case @reason
|
44
|
+
when Integer
|
45
|
+
"Bug Filed: #{@tracker}/#{@reason}"
|
46
|
+
when Symbol
|
47
|
+
@messages[@reason]
|
48
|
+
when String
|
49
|
+
@reason
|
50
|
+
else
|
51
|
+
'no reason given'
|
52
|
+
end
|
53
|
+
|
54
|
+
case @type
|
55
|
+
when :exclude
|
56
|
+
"Test skipped because it breaks test run; #{details}"
|
57
|
+
when :flaky
|
58
|
+
"Test skipped because it is unreliable in this configuration; #{details}"
|
59
|
+
when :exclusive
|
60
|
+
"Test does not apply to this configuration; #{details}"
|
61
|
+
else
|
62
|
+
"Test guarded; #{details}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# Bug is present on all configurations specified
|
67
|
+
def except?
|
68
|
+
@type == :except
|
69
|
+
end
|
70
|
+
|
71
|
+
# Bug is present on all configurations not specified
|
72
|
+
def only?
|
73
|
+
@type == :only
|
74
|
+
end
|
75
|
+
|
76
|
+
# Bug is present on all configurations specified, but test can not be run because it breaks other tests,
|
77
|
+
# or it is flaky and unreliable
|
78
|
+
def exclude?
|
79
|
+
@type == :exclude || @type == :flaky
|
80
|
+
end
|
81
|
+
|
82
|
+
# Test only applies to configurations specified
|
83
|
+
def exclusive?
|
84
|
+
@type == :exclusive
|
85
|
+
end
|
86
|
+
end # Guard
|
87
|
+
end # Guards
|
88
|
+
end # Support
|
89
|
+
end # WebDriver
|
90
|
+
end # Selenium
|
data/lib/selenium/webdriver/{firefox/marionette/bridge.rb → support/guards/guard_condition.rb}
RENAMED
@@ -19,31 +19,32 @@
|
|
19
19
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
|
-
module
|
23
|
-
|
24
|
-
|
22
|
+
module Support
|
23
|
+
class Guards
|
24
|
+
#
|
25
|
+
# Guard derived from RSpec example metadata.
|
26
|
+
# @api private
|
27
|
+
#
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
uninstall_addon: [:post, 'session/:session_id/moz/addon/uninstall']
|
29
|
-
}.freeze
|
29
|
+
class GuardCondition
|
30
|
+
attr_accessor :name, :execution
|
30
31
|
|
31
|
-
def
|
32
|
-
|
32
|
+
def initialize(name, condition = nil, &blk)
|
33
|
+
@name = name
|
34
|
+
@execution = if blk
|
35
|
+
proc(&blk)
|
36
|
+
else
|
37
|
+
proc { |guarded| guarded.include?(condition) }
|
38
|
+
end
|
33
39
|
end
|
34
40
|
|
35
|
-
def
|
36
|
-
|
37
|
-
payload[:temporary] = temporary unless temporary.nil?
|
38
|
-
execute :install_addon, {}, payload
|
39
|
-
end
|
41
|
+
def satisfied?(guard)
|
42
|
+
list = Array(guard.guarded[@name])
|
40
43
|
|
41
|
-
|
42
|
-
execute :uninstall_addon, {}, {id: id}
|
44
|
+
list.empty? || @execution.call(list)
|
43
45
|
end
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
end # Firefox
|
46
|
+
end # GuardCondition
|
47
|
+
end # Guards
|
48
|
+
end # Support
|
48
49
|
end # WebDriver
|
49
50
|
end # Selenium
|
@@ -0,0 +1,95 @@
|
|
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
|
+
require_relative 'guards/guard_condition'
|
21
|
+
require_relative 'guards/guard'
|
22
|
+
|
23
|
+
module Selenium
|
24
|
+
module WebDriver
|
25
|
+
module Support
|
26
|
+
class Guards
|
27
|
+
GUARD_TYPES = %i[except only exclude exclusive flaky].freeze
|
28
|
+
|
29
|
+
attr_reader :messages
|
30
|
+
attr_accessor :bug_tracker
|
31
|
+
|
32
|
+
def initialize(example, bug_tracker: '', conditions: nil)
|
33
|
+
@example = example
|
34
|
+
@bug_tracker = bug_tracker
|
35
|
+
@guard_conditions = conditions || []
|
36
|
+
@guards = collect_example_guards
|
37
|
+
@messages = {}
|
38
|
+
end
|
39
|
+
|
40
|
+
def add_condition(name, condition = nil, &blk)
|
41
|
+
@guard_conditions << GuardCondition.new(name, condition, &blk)
|
42
|
+
end
|
43
|
+
|
44
|
+
def add_message(name, message)
|
45
|
+
@messages[name] = message
|
46
|
+
end
|
47
|
+
|
48
|
+
def disposition
|
49
|
+
if !skipping_guard.nil?
|
50
|
+
[:skip, skipping_guard.message]
|
51
|
+
elsif !pending_guard.nil? && ENV.fetch('SKIP_PENDING', nil)
|
52
|
+
[:skip, pending_guard.message]
|
53
|
+
elsif !pending_guard.nil?
|
54
|
+
[:pending, pending_guard.message]
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def satisfied?(guard)
|
59
|
+
@guard_conditions.all? { |condition| condition.satisfied?(guard) }
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def collect_example_guards
|
65
|
+
guards = []
|
66
|
+
|
67
|
+
GUARD_TYPES.each do |guard_type|
|
68
|
+
example_group = @example.metadata[:example_group]
|
69
|
+
example_guards = [@example.metadata[guard_type], example_group[guard_type]]
|
70
|
+
while example_group[:parent_example_group]
|
71
|
+
example_group = example_group[:parent_example_group]
|
72
|
+
example_guards << example_group[guard_type]
|
73
|
+
end
|
74
|
+
|
75
|
+
example_guards.flatten.uniq.compact.each do |example_guard|
|
76
|
+
guards << Guard.new(example_guard, guard_type, self)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
guards
|
81
|
+
end
|
82
|
+
|
83
|
+
def skipping_guard
|
84
|
+
@guards.select(&:exclusive?).find { |guard| !satisfied?(guard) } ||
|
85
|
+
@guards.select(&:exclude?).find { |guard| satisfied?(guard) }
|
86
|
+
end
|
87
|
+
|
88
|
+
def pending_guard
|
89
|
+
@guards.select(&:except?).find { |guard| satisfied?(guard) } ||
|
90
|
+
@guards.select(&:only?).find { |guard| !satisfied?(guard) }
|
91
|
+
end
|
92
|
+
end # Guards
|
93
|
+
end # Support
|
94
|
+
end # WebDriver
|
95
|
+
end # Selenium
|
@@ -0,0 +1,50 @@
|
|
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 Support
|
23
|
+
#
|
24
|
+
# @api private
|
25
|
+
#
|
26
|
+
|
27
|
+
class RelativeLocator
|
28
|
+
KEYS = %w[above below left right near distance].freeze
|
29
|
+
|
30
|
+
def initialize(locator)
|
31
|
+
@filters, @root = locator.partition { |how, _| KEYS.include?(how) }.map(&:to_h)
|
32
|
+
end
|
33
|
+
|
34
|
+
def as_json
|
35
|
+
{
|
36
|
+
relative: {
|
37
|
+
root: @root,
|
38
|
+
filters: @filters.map do |kind, filter|
|
39
|
+
{
|
40
|
+
kind: kind,
|
41
|
+
args: [filter]
|
42
|
+
}
|
43
|
+
end
|
44
|
+
}
|
45
|
+
}
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -31,7 +31,7 @@ module Selenium
|
|
31
31
|
raise ArgumentError, "unexpected tag name #{tag_name.inspect}" unless tag_name.casecmp('select').zero?
|
32
32
|
|
33
33
|
@element = element
|
34
|
-
@multi = ![nil, 'false'].include?(element.
|
34
|
+
@multi = ![nil, 'false'].include?(element.dom_attribute(:multiple))
|
35
35
|
end
|
36
36
|
|
37
37
|
#
|
@@ -86,7 +86,7 @@ module Selenium
|
|
86
86
|
#
|
87
87
|
# <option value="foo">Bar</option>
|
88
88
|
#
|
89
|
-
# When
|
89
|
+
# When selecting by :value, selects all options that have a value matching the argument. That is, when given "foo" this
|
90
90
|
# would select an option like:
|
91
91
|
#
|
92
92
|
# <option value="foo">Bar</option>
|
@@ -215,6 +215,8 @@ module Selenium
|
|
215
215
|
end
|
216
216
|
|
217
217
|
def select_option(option)
|
218
|
+
raise Error::UnsupportedOperationError, 'You may not select a disabled option' unless option.enabled?
|
219
|
+
|
218
220
|
option.click unless option.selected?
|
219
221
|
end
|
220
222
|
|
@@ -242,7 +244,7 @@ module Selenium
|
|
242
244
|
xpath = ".//option[normalize-space(.) = #{Escaper.escape text}]"
|
243
245
|
opts = @element.find_elements(xpath: xpath)
|
244
246
|
|
245
|
-
return opts unless opts.empty? &&
|
247
|
+
return opts unless opts.empty? && /\s+/.match?(text)
|
246
248
|
|
247
249
|
longest_word = text.split(/\s+/).max_by(&:length)
|
248
250
|
if longest_word.empty?
|
@@ -258,7 +260,7 @@ module Selenium
|
|
258
260
|
end
|
259
261
|
|
260
262
|
def find_by_index(index)
|
261
|
-
options.select { |option| option.
|
263
|
+
options.select { |option| option.property(:index) == index }
|
262
264
|
end
|
263
265
|
|
264
266
|
def find_by_value(value)
|
data/lib/selenium/webdriver.rb
CHANGED
@@ -17,15 +17,16 @@
|
|
17
17
|
# specific language governing permissions and limitations
|
18
18
|
# under the License.
|
19
19
|
|
20
|
-
require 'childprocess'
|
21
20
|
require 'tmpdir'
|
22
21
|
require 'fileutils'
|
23
22
|
require 'date'
|
24
23
|
require 'json'
|
25
24
|
require 'set'
|
25
|
+
require 'uri'
|
26
|
+
require 'net/http'
|
26
27
|
|
27
|
-
require 'selenium/webdriver/common'
|
28
28
|
require 'selenium/webdriver/atoms'
|
29
|
+
require 'selenium/webdriver/common'
|
29
30
|
require 'selenium/webdriver/version'
|
30
31
|
|
31
32
|
module Selenium
|
@@ -33,16 +34,17 @@ module Selenium
|
|
33
34
|
Point = Struct.new(:x, :y)
|
34
35
|
Dimension = Struct.new(:width, :height)
|
35
36
|
Rectangle = Struct.new(:x, :y, :width, :height)
|
36
|
-
Location = Struct.new(:latitude, :longitude, :altitude)
|
37
37
|
|
38
|
-
autoload :
|
39
|
-
autoload :
|
40
|
-
autoload :
|
41
|
-
autoload :
|
42
|
-
autoload :
|
43
|
-
autoload :
|
44
|
-
autoload :
|
45
|
-
autoload :
|
38
|
+
autoload :BiDi, 'selenium/webdriver/bidi'
|
39
|
+
autoload :Chromium, 'selenium/webdriver/chromium'
|
40
|
+
autoload :Chrome, 'selenium/webdriver/chrome'
|
41
|
+
autoload :DevTools, 'selenium/webdriver/devtools'
|
42
|
+
autoload :Edge, 'selenium/webdriver/edge'
|
43
|
+
autoload :Firefox, 'selenium/webdriver/firefox'
|
44
|
+
autoload :IE, 'selenium/webdriver/ie'
|
45
|
+
autoload :Remote, 'selenium/webdriver/remote'
|
46
|
+
autoload :Safari, 'selenium/webdriver/safari'
|
47
|
+
autoload :Support, 'selenium/webdriver/support'
|
46
48
|
|
47
49
|
# @api private
|
48
50
|
|
@@ -54,10 +56,10 @@ module Selenium
|
|
54
56
|
# Create a new Driver instance with the correct bridge for the given browser
|
55
57
|
#
|
56
58
|
# @overload for(browser)
|
57
|
-
# @param [:ie, :internet_explorer, :edge, :remote, :chrome, :firefox, :ff, :
|
59
|
+
# @param [:ie, :internet_explorer, :edge, :remote, :chrome, :firefox, :ff, :safari] browser The browser to
|
58
60
|
# create the driver for
|
59
61
|
# @overload for(browser, opts)
|
60
|
-
# @param [:ie, :internet_explorer, :edge, :remote, :chrome, :firefox, :ff, :
|
62
|
+
# @param [:ie, :internet_explorer, :edge, :remote, :chrome, :firefox, :ff, :safari] browser The browser to
|
61
63
|
# create the driver for
|
62
64
|
# @param [Hash] opts Options passed to Driver.new
|
63
65
|
#
|
@@ -68,14 +70,13 @@ module Selenium
|
|
68
70
|
# @see Selenium::WebDriver::IE::Driver
|
69
71
|
# @see Selenium::WebDriver::Edge::Driver
|
70
72
|
# @see Selenium::WebDriver::Chrome::Driver
|
71
|
-
# @see Selenium::WebDriver::PhantomJS::Driver
|
72
73
|
# @see Selenium::WebDriver::Safari::Driver
|
73
74
|
#
|
74
75
|
# @example
|
75
76
|
#
|
76
77
|
# WebDriver.for :firefox, profile: 'some-profile'
|
77
78
|
# WebDriver.for :firefox, profile: Profile.new
|
78
|
-
# WebDriver.for :remote, url: "http://localhost:4444/wd/hub",
|
79
|
+
# WebDriver.for :remote, url: "http://localhost:4444/wd/hub", capabilities: caps
|
79
80
|
#
|
80
81
|
# One special argument is not passed on to the bridges, :listener.
|
81
82
|
# You can pass a listener for this option to get notified of WebDriver events.
|
@@ -94,8 +95,9 @@ module Selenium
|
|
94
95
|
# @return [Logger]
|
95
96
|
#
|
96
97
|
|
97
|
-
def self.logger
|
98
|
-
|
98
|
+
def self.logger(**opts)
|
99
|
+
level = $DEBUG || ENV.key?('DEBUG') ? :debug : :info
|
100
|
+
@logger ||= WebDriver::Logger.new('Selenium', default_level: level, **opts)
|
99
101
|
end
|
100
102
|
end # WebDriver
|
101
103
|
end # Selenium
|
data/selenium-webdriver.gemspec
CHANGED
@@ -11,37 +11,55 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.version = Selenium::WebDriver::VERSION
|
12
12
|
|
13
13
|
s.authors = ['Alex Rodionov', 'Titus Fortner', 'Thomas Walpole']
|
14
|
-
s.email = [
|
14
|
+
s.email = %w[p0deje@gmail.com titusfortner@gmail.com twalpole@gmail.com]
|
15
15
|
|
16
|
-
s.summary = '
|
17
|
-
s.description =
|
18
|
-
|
19
|
-
|
16
|
+
s.summary = 'Selenium is a browser automation tool for automated testing of webapps and more'
|
17
|
+
s.description = <<-DESCRIPTION
|
18
|
+
Selenium implements the W3C WebDriver protocol to automate popular browsers.
|
19
|
+
It aims to mimic the behaviour of a real user as it interacts with the application's HTML.
|
20
|
+
It's primarily intended for web application testing, but any web-based task can automated.
|
21
|
+
DESCRIPTION
|
20
22
|
|
21
23
|
s.license = 'Apache-2.0'
|
22
|
-
s.homepage = 'https://
|
24
|
+
s.homepage = 'https://selenium.dev'
|
23
25
|
s.metadata = {
|
24
|
-
'changelog_uri' => 'https://github.com/SeleniumHQ/selenium/blob/
|
25
|
-
'
|
26
|
+
'changelog_uri' => 'https://github.com/SeleniumHQ/selenium/blob/trunk/rb/CHANGES',
|
27
|
+
'github_repo' => 'ssh://github.com/SeleniumHQ/selenium',
|
28
|
+
'source_code_uri' => 'https://github.com/SeleniumHQ/selenium/tree/trunk/rb',
|
29
|
+
'rubygems_mfa_required' => 'true'
|
26
30
|
}
|
27
31
|
|
28
32
|
s.required_rubygems_version = Gem::Requirement.new('> 1.3.1') if s.respond_to? :required_rubygems_version=
|
29
|
-
s.required_ruby_version = Gem::Requirement.new('>=
|
33
|
+
s.required_ruby_version = Gem::Requirement.new('>= 3.0')
|
30
34
|
|
31
|
-
s.files =
|
35
|
+
s.files = [
|
36
|
+
'CHANGES',
|
37
|
+
'LICENSE',
|
38
|
+
'NOTICE',
|
39
|
+
'Gemfile',
|
40
|
+
'README.md',
|
41
|
+
'selenium-webdriver.gemspec',
|
42
|
+
'lib/selenium-webdriver.rb',
|
43
|
+
'lib/selenium/server.rb',
|
44
|
+
'lib/selenium/webdriver.rb'
|
45
|
+
]
|
46
|
+
s.files += Dir['bin/**/*']
|
47
|
+
s.files += Dir['lib/selenium/webdriver/**/*']
|
48
|
+
|
49
|
+
s.bindir = 'bin'
|
32
50
|
s.require_paths = ['lib']
|
33
51
|
|
34
|
-
s.add_runtime_dependency '
|
35
|
-
s.add_runtime_dependency 'rubyzip', ['>= 1.2.2']
|
52
|
+
s.add_runtime_dependency 'rexml', ['~> 3.2', '>= 3.2.5']
|
53
|
+
s.add_runtime_dependency 'rubyzip', ['>= 1.2.2', '< 3.0']
|
54
|
+
s.add_runtime_dependency 'websocket', ['~> 1.0']
|
36
55
|
|
37
|
-
# childprocess requires ffi on windows but doesn't declare it in its dependencies
|
38
|
-
s.add_development_dependency 'ffi'
|
39
56
|
s.add_development_dependency 'rack', ['~> 2.0']
|
40
|
-
s.add_development_dependency 'rake'
|
57
|
+
s.add_development_dependency 'rake', ['~> 13.0']
|
41
58
|
s.add_development_dependency 'rspec', ['~> 3.0']
|
42
|
-
s.add_development_dependency 'rubocop', ['~>
|
43
|
-
s.add_development_dependency 'rubocop-performance'
|
44
|
-
s.add_development_dependency 'rubocop-rspec'
|
59
|
+
s.add_development_dependency 'rubocop', ['~> 1.42']
|
60
|
+
s.add_development_dependency 'rubocop-performance', ['~> 1.15']
|
61
|
+
s.add_development_dependency 'rubocop-rspec', ['~> 2.16']
|
45
62
|
s.add_development_dependency 'webmock', ['~> 3.5']
|
63
|
+
s.add_development_dependency 'webrick', ['~> 1.7']
|
46
64
|
s.add_development_dependency 'yard', ['~> 0.9.11']
|
47
65
|
end
|