selenium-webdriver 3.142.7 → 4.10.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 +611 -5
- data/Gemfile +5 -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 +94 -79
- data/lib/selenium/webdriver/atoms/findElements.js +121 -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/atoms.rb +2 -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 +44 -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 +6 -33
- data/lib/selenium/webdriver/chrome.rb +5 -18
- data/lib/selenium/webdriver/chromium/driver.rb +61 -0
- data/lib/selenium/webdriver/{chrome/bridge.rb → chromium/features.rb} +51 -16
- data/lib/selenium/webdriver/chromium/options.rb +261 -0
- data/lib/selenium/webdriver/chromium/profile.rb +113 -0
- data/lib/selenium/webdriver/chromium/service.rb +42 -0
- data/lib/selenium/webdriver/chromium.rb +32 -0
- data/lib/selenium/webdriver/common/action_builder.rb +128 -238
- data/lib/selenium/webdriver/common/child_process.rb +124 -0
- data/lib/selenium/webdriver/common/driver.rb +94 -43
- data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +42 -0
- 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_launching.rb +36 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +5 -9
- 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_connection.rb +6 -27
- 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 +47 -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 +55 -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 +169 -23
- data/lib/selenium/webdriver/common/platform.rb +14 -6
- 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 +125 -0
- data/lib/selenium/webdriver/common/service.rb +26 -137
- 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 +42 -18
- 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 +44 -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 +7 -27
- data/lib/selenium/webdriver/edge.rb +11 -14
- 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 +66 -0
- data/lib/selenium/webdriver/firefox/options.rb +77 -50
- data/lib/selenium/webdriver/firefox/profile.rb +17 -71
- data/lib/selenium/webdriver/firefox/service.rb +3 -13
- 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/options.rb +15 -46
- data/lib/selenium/webdriver/ie/service.rb +11 -19
- data/lib/selenium/webdriver/ie.rb +3 -16
- data/lib/selenium/webdriver/remote/bridge/commands.rb +170 -0
- data/lib/selenium/webdriver/remote/bridge.rb +592 -87
- data/lib/selenium/webdriver/remote/capabilities.rb +182 -124
- data/lib/selenium/webdriver/remote/driver.rb +30 -15
- 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 +23 -31
- data/lib/selenium/webdriver/remote/response.rb +17 -49
- data/lib/selenium/webdriver/remote.rb +14 -12
- data/lib/selenium/webdriver/safari/driver.rb +7 -29
- data/lib/selenium/webdriver/safari/{bridge.rb → features.rb} +3 -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 +4 -4
- data/lib/selenium/webdriver/support/guards/guard.rb +87 -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 +18 -17
- data/selenium-webdriver.gemspec +36 -18
- metadata +159 -89
- 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/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
@@ -20,7 +20,6 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Atoms
|
23
|
-
|
24
23
|
private
|
25
24
|
|
26
25
|
def read_atom(function)
|
@@ -28,10 +27,10 @@ module Selenium
|
|
28
27
|
end
|
29
28
|
|
30
29
|
def execute_atom(function_name, *arguments)
|
31
|
-
script = format("return (%<atom>s).apply(null, arguments)",
|
30
|
+
script = format("/* #{function_name} */return (%<atom>s).apply(null, arguments)",
|
31
|
+
atom: read_atom(function_name))
|
32
32
|
execute_script(script, *arguments)
|
33
33
|
end
|
34
|
-
|
35
34
|
end # Atoms
|
36
35
|
end # WebDriver
|
37
36
|
end # Selenium
|
@@ -0,0 +1,88 @@
|
|
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 'navigate_result'
|
21
|
+
require_relative 'browsing_context_info'
|
22
|
+
|
23
|
+
module Selenium
|
24
|
+
module WebDriver
|
25
|
+
class BiDi
|
26
|
+
class BrowsingContext
|
27
|
+
attr_accessor :id
|
28
|
+
|
29
|
+
READINESS_STATE = {
|
30
|
+
none: 'none',
|
31
|
+
interactive: 'interactive',
|
32
|
+
complete: 'complete'
|
33
|
+
}.freeze
|
34
|
+
|
35
|
+
def initialize(driver:, browsing_context_id: nil, type: nil, reference_context: nil)
|
36
|
+
unless driver.capabilities.web_socket_url
|
37
|
+
raise Error::WebDriverError,
|
38
|
+
'WebDriver instance must support BiDi protocol'
|
39
|
+
end
|
40
|
+
|
41
|
+
unless type.nil? || %i[window tab].include?(type)
|
42
|
+
raise ArgumentError,
|
43
|
+
"Valid types are :window & :tab. Received: #{type.inspect}"
|
44
|
+
end
|
45
|
+
|
46
|
+
@bidi = driver.bidi
|
47
|
+
@id = browsing_context_id.nil? ? create(type, reference_context)['context'] : browsing_context_id
|
48
|
+
end
|
49
|
+
|
50
|
+
def navigate(url:, readiness_state: nil)
|
51
|
+
unless readiness_state.nil? || READINESS_STATE.key?(readiness_state)
|
52
|
+
raise ArgumentError,
|
53
|
+
"Valid readiness states are :none, :interactive & :complete. Received: #{readiness_state.inspect}"
|
54
|
+
end
|
55
|
+
|
56
|
+
navigate_result = @bidi.send_cmd('browsingContext.navigate', context: @id, url: url,
|
57
|
+
wait: READINESS_STATE[readiness_state])
|
58
|
+
|
59
|
+
NavigateResult.new(
|
60
|
+
url: navigate_result['url'],
|
61
|
+
navigation_id: navigate_result['navigation']
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
def get_tree(max_depth: nil)
|
66
|
+
result = @bidi.send_cmd('browsingContext.getTree', root: @id, maxDepth: max_depth).dig('contexts', 0)
|
67
|
+
|
68
|
+
BrowsingContextInfo.new(
|
69
|
+
id: result['context'],
|
70
|
+
url: result['url'],
|
71
|
+
children: result['children'],
|
72
|
+
parent_context: result['parent']
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
def close
|
77
|
+
@bidi.send_cmd('browsingContext.close', context: @id)
|
78
|
+
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def create(type, reference_context)
|
83
|
+
@bidi.send_cmd('browsingContext.create', type: type.to_s, referenceContext: reference_context)
|
84
|
+
end
|
85
|
+
end # BrowsingContext
|
86
|
+
end # BiDi
|
87
|
+
end # WebDriver
|
88
|
+
end # Selenium
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
class BiDi
|
23
|
+
class BrowsingContextInfo
|
24
|
+
attr_accessor :id, :url, :children, :parent_browsing_context
|
25
|
+
|
26
|
+
def initialize(id:, url:, children:, parent_context:)
|
27
|
+
@id = id
|
28
|
+
@url = url
|
29
|
+
@children = children
|
30
|
+
@parent_browsing_context = parent_context
|
31
|
+
end
|
32
|
+
end # BrowsingContextInfo
|
33
|
+
end # BiDi
|
34
|
+
end # WebDriver
|
35
|
+
end # Selenium
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
class BiDi
|
23
|
+
class BaseLogEntry
|
24
|
+
attr_accessor :level, :text, :timestamp, :stack_trace
|
25
|
+
|
26
|
+
def initialize(level:, text:, timestamp:, stack_trace:)
|
27
|
+
@level = level
|
28
|
+
@text = text
|
29
|
+
@timestamp = timestamp
|
30
|
+
@stack_trace = stack_trace
|
31
|
+
end
|
32
|
+
end # BaseLogEntry
|
33
|
+
end # BiDi
|
34
|
+
end # WebDriver
|
35
|
+
end # Selenium
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
class BiDi
|
23
|
+
class ConsoleLogEntry < GenericLogEntry
|
24
|
+
attr_accessor :method, :realm, :args
|
25
|
+
|
26
|
+
def initialize(method:, realm:, args:, **opts)
|
27
|
+
super(**opts)
|
28
|
+
@method = method
|
29
|
+
@realm = realm
|
30
|
+
@args = args
|
31
|
+
end
|
32
|
+
end # ConsoleLogEntry
|
33
|
+
end # BiDi
|
34
|
+
end # WebDriver
|
35
|
+
end # Selenium
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
class BiDi
|
23
|
+
class FilterBy
|
24
|
+
attr_accessor :level
|
25
|
+
|
26
|
+
def initialize(level)
|
27
|
+
@level = level
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.log_level(level = nil)
|
31
|
+
unless %w[debug error info warning].include?(level)
|
32
|
+
raise Error::WebDriverError,
|
33
|
+
"Valid log levels are 'debug', 'error', 'info' and 'warning'. Received: #{level}"
|
34
|
+
end
|
35
|
+
FilterBy.new(level)
|
36
|
+
end
|
37
|
+
end # FilterBy
|
38
|
+
end # BiDi
|
39
|
+
end # WebDriver
|
40
|
+
end # Selenium
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
class BiDi
|
23
|
+
class GenericLogEntry < BaseLogEntry
|
24
|
+
attr_accessor :type
|
25
|
+
|
26
|
+
def initialize(level:, text:, timestamp:, type:, stack_trace:)
|
27
|
+
super(level: level, text: text, timestamp: timestamp, stack_trace: stack_trace)
|
28
|
+
@type = type
|
29
|
+
end
|
30
|
+
end # GenericLogEntry
|
31
|
+
end # BiDi
|
32
|
+
end # WebDriver
|
33
|
+
end # Selenium
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
class BiDi
|
23
|
+
class JavascriptLogEntry < GenericLogEntry
|
24
|
+
attr_accessor :type
|
25
|
+
|
26
|
+
def initialize(level:, text:, timestamp:, type:, stack_trace:)
|
27
|
+
super(level: level, text: text, timestamp: timestamp, type: type, stack_trace: stack_trace)
|
28
|
+
@type = 'javascript'
|
29
|
+
end
|
30
|
+
end # JavascriptLogEntry
|
31
|
+
end # BiDi
|
32
|
+
end # WebDriver
|
33
|
+
end # Selenium
|
@@ -0,0 +1,143 @@
|
|
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
|
+
# This file is automatically generated. Any changes will be lost!
|
21
|
+
|
22
|
+
require_relative 'log/base_log_entry'
|
23
|
+
require_relative 'log/generic_log_entry'
|
24
|
+
require_relative 'log/console_log_entry'
|
25
|
+
require_relative 'log/javascript_log_entry'
|
26
|
+
require_relative 'log/filter_by'
|
27
|
+
|
28
|
+
module Selenium
|
29
|
+
module WebDriver
|
30
|
+
class BiDi
|
31
|
+
class LogInspector
|
32
|
+
EVENTS = {
|
33
|
+
entry_added: 'entryAdded'
|
34
|
+
}.freeze
|
35
|
+
|
36
|
+
LOG_LEVEL = {
|
37
|
+
DEBUG: 'debug',
|
38
|
+
ERROR: 'error',
|
39
|
+
INFO: 'info',
|
40
|
+
WARNING: 'warning'
|
41
|
+
}.freeze
|
42
|
+
|
43
|
+
def initialize(driver, browsing_context_ids = nil)
|
44
|
+
unless driver.capabilities.web_socket_url
|
45
|
+
raise Error::WebDriverError,
|
46
|
+
'WebDriver instance must support BiDi protocol'
|
47
|
+
end
|
48
|
+
|
49
|
+
@bidi = driver.bidi
|
50
|
+
@bidi.session.subscribe('log.entryAdded', browsing_context_ids)
|
51
|
+
end
|
52
|
+
|
53
|
+
def on_console_entry(filter_by = nil, &block)
|
54
|
+
check_valid_filter(filter_by)
|
55
|
+
|
56
|
+
on_log do |params|
|
57
|
+
type = params['type']
|
58
|
+
console_log_events(params, filter_by, &block) if type.eql?('console')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def on_javascript_log(filter_by = nil, &block)
|
63
|
+
check_valid_filter(filter_by)
|
64
|
+
|
65
|
+
on_log do |params|
|
66
|
+
type = params['type']
|
67
|
+
javascript_log_events(params, filter_by, &block) if type.eql?('javascript')
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def on_javascript_exception(&block)
|
72
|
+
on_log do |params|
|
73
|
+
type = params['type']
|
74
|
+
javascript_log_events(params, FilterBy.log_level('error'), &block) if type.eql?('javascript')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def on_log(filter_by = nil, &block)
|
79
|
+
unless filter_by.nil?
|
80
|
+
check_valid_filter(filter_by)
|
81
|
+
|
82
|
+
on(:entry_added) do |params|
|
83
|
+
yield(params) if params['level'] == filter_by.level
|
84
|
+
end
|
85
|
+
return
|
86
|
+
end
|
87
|
+
|
88
|
+
on(:entry_added, &block)
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
def on(event, &block)
|
94
|
+
event = EVENTS[event] if event.is_a?(Symbol)
|
95
|
+
@bidi.callbacks["log.#{event}"] << block
|
96
|
+
end
|
97
|
+
|
98
|
+
def check_valid_filter(filter_by)
|
99
|
+
return if filter_by.nil? || filter_by.instance_of?(FilterBy)
|
100
|
+
|
101
|
+
raise "Pass valid FilterBy object. Received: #{filter_by.inspect}"
|
102
|
+
end
|
103
|
+
|
104
|
+
def console_log_events(params, filter_by)
|
105
|
+
event = ConsoleLogEntry.new(
|
106
|
+
level: params['level'],
|
107
|
+
text: params['text'],
|
108
|
+
timestamp: params['timestamp'],
|
109
|
+
type: params['type'],
|
110
|
+
method: params['method'],
|
111
|
+
realm: params['realm'],
|
112
|
+
args: params['args'],
|
113
|
+
stack_trace: params['stackTrace']
|
114
|
+
)
|
115
|
+
|
116
|
+
unless filter_by.nil?
|
117
|
+
yield(event) if params['level'] == filter_by.level
|
118
|
+
return
|
119
|
+
end
|
120
|
+
|
121
|
+
yield(event)
|
122
|
+
end
|
123
|
+
|
124
|
+
def javascript_log_events(params, filter_by)
|
125
|
+
event = JavascriptLogEntry.new(
|
126
|
+
level: params['level'],
|
127
|
+
text: params['text'],
|
128
|
+
timestamp: params['timestamp'],
|
129
|
+
type: params['type'],
|
130
|
+
stack_trace: params['stackTrace']
|
131
|
+
)
|
132
|
+
|
133
|
+
unless filter_by.nil?
|
134
|
+
yield(event) if params['level'] == filter_by.level
|
135
|
+
return
|
136
|
+
end
|
137
|
+
|
138
|
+
yield(event)
|
139
|
+
end
|
140
|
+
end # LogInspector
|
141
|
+
end # Bidi
|
142
|
+
end # WebDriver
|
143
|
+
end # Selenium
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
class BiDi
|
23
|
+
class NavigateResult
|
24
|
+
attr_accessor :url, :navigation_id
|
25
|
+
|
26
|
+
def initialize(url:, navigation_id:)
|
27
|
+
@url = url
|
28
|
+
@navigation_id = navigation_id
|
29
|
+
end
|
30
|
+
end # NavigateResult
|
31
|
+
end # BiDi
|
32
|
+
end # WebDriver
|
33
|
+
end # Selenium
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
5
|
+
# distributed with this work for additional information
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
8
|
+
# "License"); you may not use this file except in compliance
|
9
|
+
# with the License. You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
14
|
+
# software distributed under the License is distributed on an
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
16
|
+
# KIND, either express or implied. See the License for the
|
17
|
+
# specific language governing permissions and limitations
|
18
|
+
# under the License.
|
19
|
+
|
20
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
class BiDi
|
23
|
+
class Session
|
24
|
+
Status = Struct.new(:ready, :message)
|
25
|
+
|
26
|
+
def initialize(bidi)
|
27
|
+
@bidi = bidi
|
28
|
+
end
|
29
|
+
|
30
|
+
def status
|
31
|
+
status = @bidi.send_cmd('session.status')
|
32
|
+
Status.new(status['ready'], status['message'])
|
33
|
+
end
|
34
|
+
|
35
|
+
def subscribe(events, browsing_contexts = nil)
|
36
|
+
events_list = Array(events)
|
37
|
+
browsing_contexts_list = browsing_contexts.nil? ? nil : Array(browsing_contexts)
|
38
|
+
|
39
|
+
@bidi.send_cmd('session.subscribe', events: events_list, contexts: browsing_contexts_list)
|
40
|
+
end
|
41
|
+
|
42
|
+
def unsubscribe(events, browsing_contexts = nil)
|
43
|
+
events_list = Array(events)
|
44
|
+
browsing_contexts_list = browsing_contexts.nil? ? nil : Array(browsing_contexts)
|
45
|
+
|
46
|
+
@bidi.send_cmd('session.unsubscribe', events: events_list, contexts: browsing_contexts_list)
|
47
|
+
end
|
48
|
+
end # Session
|
49
|
+
end # BiDi
|
50
|
+
end # WebDriver
|
51
|
+
end # Selenium
|
@@ -19,52 +19,38 @@
|
|
19
19
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
|
-
|
23
|
-
|
24
|
-
|
22
|
+
class BiDi
|
23
|
+
autoload :Session, 'selenium/webdriver/bidi/session'
|
24
|
+
autoload :LogInspector, 'selenium/webdriver/bidi/log_inspector'
|
25
|
+
autoload :BrowsingContext, 'selenium/webdriver/bidi/browsing_context'
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
@bridge = bridge
|
27
|
+
def initialize(url:)
|
28
|
+
@ws = WebSocketConnection.new(url: url)
|
29
29
|
end
|
30
30
|
|
31
|
-
def
|
32
|
-
@
|
31
|
+
def close
|
32
|
+
@ws.close
|
33
33
|
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
#
|
38
|
-
# @see Selenium::WebDriver::Keys
|
39
|
-
#
|
40
|
-
|
41
|
-
def press(key)
|
42
|
-
assert_modifier key
|
43
|
-
|
44
|
-
@bridge.send_keys_to_active_element Keys.encode([key])
|
35
|
+
def callbacks
|
36
|
+
@ws.callbacks
|
45
37
|
end
|
46
38
|
|
47
|
-
|
48
|
-
|
49
|
-
#
|
50
|
-
# @see Selenium::WebDriver::Keys
|
51
|
-
#
|
52
|
-
|
53
|
-
def release(key)
|
54
|
-
assert_modifier key
|
55
|
-
|
56
|
-
@bridge.send_keys_to_active_element Keys.encode([key])
|
39
|
+
def session
|
40
|
+
@session ||= Session.new(self)
|
57
41
|
end
|
58
42
|
|
59
|
-
|
60
|
-
|
61
|
-
|
43
|
+
def send_cmd(method, **params)
|
44
|
+
data = {method: method, params: params.compact}
|
45
|
+
message = @ws.send_cmd(**data)
|
46
|
+
raise Error::WebDriverError, error_message(message) if message['error']
|
62
47
|
|
63
|
-
|
64
|
-
|
48
|
+
message['result']
|
49
|
+
end
|
65
50
|
|
66
|
-
|
51
|
+
def error_message(message)
|
52
|
+
"#{message['error']}: #{message['message']}\n#{message['stacktrace']}"
|
67
53
|
end
|
68
|
-
end #
|
54
|
+
end # BiDi
|
69
55
|
end # WebDriver
|
70
56
|
end # Selenium
|