selenium-webdriver 4.0.0.alpha2 → 4.0.0.alpha7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES +172 -4
- data/LICENSE +1 -1
- data/lib/selenium/server.rb +25 -9
- data/lib/selenium/webdriver.rb +12 -8
- data/lib/selenium/webdriver/atoms/findElements.js +121 -0
- data/lib/selenium/webdriver/atoms/getAttribute.js +104 -7
- data/lib/selenium/webdriver/atoms/isDisplayed.js +76 -78
- data/lib/selenium/webdriver/atoms/mutationListener.js +38 -0
- data/lib/selenium/webdriver/chrome.rb +10 -9
- data/lib/selenium/webdriver/chrome/bridge.rb +20 -4
- data/lib/selenium/webdriver/chrome/driver.rb +7 -49
- data/lib/selenium/webdriver/chrome/options.rb +97 -57
- data/lib/selenium/webdriver/chrome/profile.rb +3 -3
- data/lib/selenium/webdriver/chrome/service.rb +0 -4
- data/lib/selenium/webdriver/common.rb +6 -1
- data/lib/selenium/webdriver/common/driver.rb +81 -17
- data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +89 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +39 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +143 -0
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +2 -1
- data/lib/selenium/webdriver/common/element.rb +5 -0
- data/lib/selenium/webdriver/common/logger.rb +48 -16
- data/lib/selenium/webdriver/common/manager.rb +5 -0
- data/lib/selenium/webdriver/common/options.rb +116 -0
- data/lib/selenium/webdriver/common/platform.rb +4 -1
- data/lib/selenium/webdriver/common/port_prober.rb +4 -6
- data/lib/selenium/webdriver/common/profile_helper.rb +10 -2
- data/lib/selenium/webdriver/common/proxy.rb +0 -0
- data/lib/selenium/webdriver/common/search_context.rb +3 -2
- data/lib/selenium/webdriver/common/service.rb +30 -113
- data/lib/selenium/webdriver/common/service_manager.rb +151 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +2 -2
- data/lib/selenium/webdriver/common/takes_screenshot.rb +63 -0
- data/lib/selenium/webdriver/common/wait.rb +1 -1
- data/lib/selenium/webdriver/devtools.rb +132 -0
- data/lib/selenium/webdriver/devtools/console_event.rb +38 -0
- data/lib/selenium/webdriver/devtools/exception_event.rb +36 -0
- data/lib/selenium/webdriver/devtools/mutation_event.rb +37 -0
- data/lib/selenium/webdriver/devtools/v84/accessibility.rb +64 -0
- data/lib/selenium/webdriver/devtools/v84/animation.rb +100 -0
- data/lib/selenium/webdriver/devtools/v84/application_cache.rb +66 -0
- data/lib/selenium/webdriver/devtools/v84/audits.rb +63 -0
- data/lib/selenium/webdriver/devtools/v84/background_service.rb +69 -0
- data/lib/selenium/webdriver/devtools/v84/browser.rb +125 -0
- data/lib/selenium/webdriver/devtools/v84/cache_storage.rb +75 -0
- data/lib/selenium/webdriver/devtools/v84/cast.rb +72 -0
- data/lib/selenium/webdriver/devtools/v84/console.rb +59 -0
- data/lib/selenium/webdriver/devtools/v84/css.rb +167 -0
- data/lib/selenium/webdriver/devtools/v84/database.rb +66 -0
- data/lib/selenium/webdriver/devtools/v84/debugger.rb +231 -0
- data/lib/selenium/webdriver/devtools/v84/device_orientation.rb +55 -0
- data/lib/selenium/webdriver/devtools/v84/dom.rb +322 -0
- data/lib/selenium/webdriver/devtools/v84/dom_debugger.rb +95 -0
- data/lib/selenium/webdriver/devtools/v84/dom_snapshot.rb +67 -0
- data/lib/selenium/webdriver/devtools/v84/dom_storage.rb +81 -0
- data/lib/selenium/webdriver/devtools/v84/emulation.rb +182 -0
- data/lib/selenium/webdriver/devtools/v84/fetch.rb +99 -0
- data/lib/selenium/webdriver/devtools/v84/headless_experimental.rb +63 -0
- data/lib/selenium/webdriver/devtools/v84/heap_profiler.rb +109 -0
- data/lib/selenium/webdriver/devtools/v84/indexed_db.rb +102 -0
- data/lib/selenium/webdriver/devtools/v84/input.rb +142 -0
- data/lib/selenium/webdriver/devtools/v84/inspector.rb +57 -0
- data/lib/selenium/webdriver/devtools/v84/io.rb +61 -0
- data/lib/selenium/webdriver/devtools/v84/layer_tree.rb +97 -0
- data/lib/selenium/webdriver/devtools/v84/log.rb +68 -0
- data/lib/selenium/webdriver/devtools/v84/media.rb +59 -0
- data/lib/selenium/webdriver/devtools/v84/memory.rb +88 -0
- data/lib/selenium/webdriver/devtools/v84/network.rb +230 -0
- data/lib/selenium/webdriver/devtools/v84/overlay.rb +159 -0
- data/lib/selenium/webdriver/devtools/v84/page.rb +376 -0
- data/lib/selenium/webdriver/devtools/v84/performance.rb +65 -0
- data/lib/selenium/webdriver/devtools/v84/profiler.rb +113 -0
- data/lib/selenium/webdriver/devtools/v84/runtime.rb +195 -0
- data/lib/selenium/webdriver/devtools/v84/schema.rb +48 -0
- data/lib/selenium/webdriver/devtools/v84/security.rb +73 -0
- data/lib/selenium/webdriver/devtools/v84/service_worker.rb +118 -0
- data/lib/selenium/webdriver/devtools/v84/storage.rb +97 -0
- data/lib/selenium/webdriver/devtools/v84/system_info.rb +52 -0
- data/lib/selenium/webdriver/devtools/v84/target.rb +143 -0
- data/lib/selenium/webdriver/devtools/v84/tethering.rb +57 -0
- data/lib/selenium/webdriver/devtools/v84/tracing.rb +78 -0
- data/lib/selenium/webdriver/devtools/v84/web_audio.rb +72 -0
- data/lib/selenium/webdriver/devtools/v84/web_authn.rb +96 -0
- data/lib/selenium/webdriver/devtools/v85/accessibility.rb +64 -0
- data/lib/selenium/webdriver/devtools/v85/animation.rb +100 -0
- data/lib/selenium/webdriver/devtools/v85/application_cache.rb +66 -0
- data/lib/selenium/webdriver/devtools/v85/audits.rb +63 -0
- data/lib/selenium/webdriver/devtools/v85/background_service.rb +69 -0
- data/lib/selenium/webdriver/devtools/v85/browser.rb +125 -0
- data/lib/selenium/webdriver/devtools/v85/cache_storage.rb +75 -0
- data/lib/selenium/webdriver/devtools/v85/cast.rb +72 -0
- data/lib/selenium/webdriver/devtools/v85/console.rb +59 -0
- data/lib/selenium/webdriver/devtools/v85/css.rb +167 -0
- data/lib/selenium/webdriver/devtools/v85/database.rb +66 -0
- data/lib/selenium/webdriver/devtools/v85/debugger.rb +231 -0
- data/lib/selenium/webdriver/devtools/v85/device_orientation.rb +55 -0
- data/lib/selenium/webdriver/devtools/v85/dom.rb +322 -0
- data/lib/selenium/webdriver/devtools/v85/dom_debugger.rb +95 -0
- data/lib/selenium/webdriver/devtools/v85/dom_snapshot.rb +67 -0
- data/lib/selenium/webdriver/devtools/v85/dom_storage.rb +81 -0
- data/lib/selenium/webdriver/devtools/v85/emulation.rb +182 -0
- data/lib/selenium/webdriver/devtools/v85/fetch.rb +99 -0
- data/lib/selenium/webdriver/devtools/v85/headless_experimental.rb +63 -0
- data/lib/selenium/webdriver/devtools/v85/heap_profiler.rb +109 -0
- data/lib/selenium/webdriver/devtools/v85/indexed_db.rb +102 -0
- data/lib/selenium/webdriver/devtools/v85/input.rb +143 -0
- data/lib/selenium/webdriver/devtools/v85/inspector.rb +57 -0
- data/lib/selenium/webdriver/devtools/v85/io.rb +61 -0
- data/lib/selenium/webdriver/devtools/v85/layer_tree.rb +97 -0
- data/lib/selenium/webdriver/devtools/v85/log.rb +68 -0
- data/lib/selenium/webdriver/devtools/v85/media.rb +59 -0
- data/lib/selenium/webdriver/devtools/v85/memory.rb +88 -0
- data/lib/selenium/webdriver/devtools/v85/network.rb +230 -0
- data/lib/selenium/webdriver/devtools/v85/overlay.rb +160 -0
- data/lib/selenium/webdriver/devtools/v85/page.rb +376 -0
- data/lib/selenium/webdriver/devtools/v85/performance.rb +65 -0
- data/lib/selenium/webdriver/devtools/v85/profiler.rb +113 -0
- data/lib/selenium/webdriver/devtools/v85/runtime.rb +196 -0
- data/lib/selenium/webdriver/devtools/v85/schema.rb +48 -0
- data/lib/selenium/webdriver/devtools/v85/security.rb +73 -0
- data/lib/selenium/webdriver/devtools/v85/service_worker.rb +118 -0
- data/lib/selenium/webdriver/devtools/v85/storage.rb +97 -0
- data/lib/selenium/webdriver/devtools/v85/system_info.rb +52 -0
- data/lib/selenium/webdriver/devtools/v85/target.rb +145 -0
- data/lib/selenium/webdriver/devtools/v85/tethering.rb +57 -0
- data/lib/selenium/webdriver/devtools/v85/tracing.rb +78 -0
- data/lib/selenium/webdriver/devtools/v85/web_audio.rb +72 -0
- data/lib/selenium/webdriver/devtools/v85/web_authn.rb +96 -0
- data/lib/selenium/webdriver/devtools/v86/accessibility.rb +64 -0
- data/lib/selenium/webdriver/devtools/v86/animation.rb +100 -0
- data/lib/selenium/webdriver/devtools/v86/application_cache.rb +66 -0
- data/lib/selenium/webdriver/devtools/v86/audits.rb +63 -0
- data/lib/selenium/webdriver/devtools/v86/background_service.rb +69 -0
- data/lib/selenium/webdriver/devtools/v86/browser.rb +125 -0
- data/lib/selenium/webdriver/devtools/v86/cache_storage.rb +75 -0
- data/lib/selenium/webdriver/devtools/v86/cast.rb +72 -0
- data/lib/selenium/webdriver/devtools/v86/console.rb +59 -0
- data/lib/selenium/webdriver/devtools/v86/css.rb +181 -0
- data/lib/selenium/webdriver/devtools/v86/database.rb +66 -0
- data/lib/selenium/webdriver/devtools/v86/debugger.rb +233 -0
- data/lib/selenium/webdriver/devtools/v86/device_orientation.rb +55 -0
- data/lib/selenium/webdriver/devtools/v86/dom.rb +329 -0
- data/lib/selenium/webdriver/devtools/v86/dom_debugger.rb +95 -0
- data/lib/selenium/webdriver/devtools/v86/dom_snapshot.rb +67 -0
- data/lib/selenium/webdriver/devtools/v86/dom_storage.rb +81 -0
- data/lib/selenium/webdriver/devtools/v86/emulation.rb +193 -0
- data/lib/selenium/webdriver/devtools/v86/fetch.rb +99 -0
- data/lib/selenium/webdriver/devtools/v86/headless_experimental.rb +63 -0
- data/lib/selenium/webdriver/devtools/v86/heap_profiler.rb +109 -0
- data/lib/selenium/webdriver/devtools/v86/indexed_db.rb +102 -0
- data/lib/selenium/webdriver/devtools/v86/input.rb +143 -0
- data/lib/selenium/webdriver/devtools/v86/inspector.rb +57 -0
- data/lib/selenium/webdriver/devtools/v86/io.rb +61 -0
- data/lib/selenium/webdriver/devtools/v86/layer_tree.rb +97 -0
- data/lib/selenium/webdriver/devtools/v86/log.rb +68 -0
- data/lib/selenium/webdriver/devtools/v86/media.rb +59 -0
- data/lib/selenium/webdriver/devtools/v86/memory.rb +88 -0
- data/lib/selenium/webdriver/devtools/v86/network.rb +235 -0
- data/lib/selenium/webdriver/devtools/v86/overlay.rb +183 -0
- data/lib/selenium/webdriver/devtools/v86/page.rb +376 -0
- data/lib/selenium/webdriver/devtools/v86/performance.rb +65 -0
- data/lib/selenium/webdriver/devtools/v86/profiler.rb +113 -0
- data/lib/selenium/webdriver/devtools/v86/runtime.rb +196 -0
- data/lib/selenium/webdriver/devtools/v86/schema.rb +48 -0
- data/lib/selenium/webdriver/devtools/v86/security.rb +73 -0
- data/lib/selenium/webdriver/devtools/v86/service_worker.rb +118 -0
- data/lib/selenium/webdriver/devtools/v86/storage.rb +97 -0
- data/lib/selenium/webdriver/devtools/v86/system_info.rb +52 -0
- data/lib/selenium/webdriver/devtools/v86/target.rb +145 -0
- data/lib/selenium/webdriver/devtools/v86/tethering.rb +57 -0
- data/lib/selenium/webdriver/devtools/v86/tracing.rb +78 -0
- data/lib/selenium/webdriver/devtools/v86/web_audio.rb +72 -0
- data/lib/selenium/webdriver/devtools/v86/web_authn.rb +102 -0
- data/lib/selenium/webdriver/devtools/v87/accessibility.rb +73 -0
- data/lib/selenium/webdriver/devtools/v87/animation.rb +100 -0
- data/lib/selenium/webdriver/devtools/v87/application_cache.rb +66 -0
- data/lib/selenium/webdriver/devtools/v87/audits.rb +63 -0
- data/lib/selenium/webdriver/devtools/v87/background_service.rb +69 -0
- data/lib/selenium/webdriver/devtools/v87/browser.rb +125 -0
- data/lib/selenium/webdriver/devtools/v87/cache_storage.rb +75 -0
- data/lib/selenium/webdriver/devtools/v87/cast.rb +72 -0
- data/lib/selenium/webdriver/devtools/v87/console.rb +59 -0
- data/lib/selenium/webdriver/devtools/v87/css.rb +181 -0
- data/lib/selenium/webdriver/devtools/v87/database.rb +66 -0
- data/lib/selenium/webdriver/devtools/v87/debugger.rb +233 -0
- data/lib/selenium/webdriver/devtools/v87/device_orientation.rb +55 -0
- data/lib/selenium/webdriver/devtools/v87/dom.rb +329 -0
- data/lib/selenium/webdriver/devtools/v87/dom_debugger.rb +95 -0
- data/lib/selenium/webdriver/devtools/v87/dom_snapshot.rb +67 -0
- data/lib/selenium/webdriver/devtools/v87/dom_storage.rb +81 -0
- data/lib/selenium/webdriver/devtools/v87/emulation.rb +193 -0
- data/lib/selenium/webdriver/devtools/v87/fetch.rb +99 -0
- data/lib/selenium/webdriver/devtools/v87/headless_experimental.rb +63 -0
- data/lib/selenium/webdriver/devtools/v87/heap_profiler.rb +109 -0
- data/lib/selenium/webdriver/devtools/v87/indexed_db.rb +102 -0
- data/lib/selenium/webdriver/devtools/v87/input.rb +143 -0
- data/lib/selenium/webdriver/devtools/v87/inspector.rb +57 -0
- data/lib/selenium/webdriver/devtools/v87/io.rb +61 -0
- data/lib/selenium/webdriver/devtools/v87/layer_tree.rb +97 -0
- data/lib/selenium/webdriver/devtools/v87/log.rb +68 -0
- data/lib/selenium/webdriver/devtools/v87/media.rb +59 -0
- data/lib/selenium/webdriver/devtools/v87/memory.rb +88 -0
- data/lib/selenium/webdriver/devtools/v87/network.rb +247 -0
- data/lib/selenium/webdriver/devtools/v87/overlay.rb +183 -0
- data/lib/selenium/webdriver/devtools/v87/page.rb +376 -0
- data/lib/selenium/webdriver/devtools/v87/performance.rb +65 -0
- data/lib/selenium/webdriver/devtools/v87/profiler.rb +125 -0
- data/lib/selenium/webdriver/devtools/v87/runtime.rb +196 -0
- data/lib/selenium/webdriver/devtools/v87/schema.rb +48 -0
- data/lib/selenium/webdriver/devtools/v87/security.rb +73 -0
- data/lib/selenium/webdriver/devtools/v87/service_worker.rb +118 -0
- data/lib/selenium/webdriver/devtools/v87/storage.rb +97 -0
- data/lib/selenium/webdriver/devtools/v87/system_info.rb +52 -0
- data/lib/selenium/webdriver/devtools/v87/target.rb +145 -0
- data/lib/selenium/webdriver/devtools/v87/tethering.rb +57 -0
- data/lib/selenium/webdriver/devtools/v87/tracing.rb +78 -0
- data/lib/selenium/webdriver/devtools/v87/web_audio.rb +72 -0
- data/lib/selenium/webdriver/devtools/v87/web_authn.rb +102 -0
- data/lib/selenium/webdriver/edge.rb +29 -9
- data/lib/selenium/webdriver/edge_chrome/bridge.rb +37 -0
- data/lib/selenium/webdriver/edge_chrome/driver.rb +48 -0
- data/lib/selenium/webdriver/edge_chrome/options.rb +37 -0
- data/lib/selenium/webdriver/edge_chrome/profile.rb +33 -0
- data/lib/selenium/webdriver/edge_chrome/service.rb +36 -0
- data/lib/selenium/webdriver/{edge → edge_html}/driver.rb +3 -35
- data/lib/selenium/webdriver/{edge → edge_html}/options.rb +26 -22
- data/lib/selenium/webdriver/{edge → edge_html}/service.rb +2 -6
- data/lib/selenium/webdriver/firefox.rb +18 -15
- data/lib/selenium/webdriver/firefox/bridge.rb +1 -1
- data/lib/selenium/webdriver/firefox/driver.rb +2 -31
- data/lib/selenium/webdriver/firefox/extension.rb +8 -0
- data/lib/selenium/webdriver/firefox/options.rb +47 -52
- data/lib/selenium/webdriver/firefox/profile.rb +7 -78
- data/lib/selenium/webdriver/firefox/service.rb +0 -4
- data/lib/selenium/webdriver/ie.rb +8 -7
- data/lib/selenium/webdriver/ie/driver.rb +0 -33
- data/lib/selenium/webdriver/ie/options.rb +10 -33
- data/lib/selenium/webdriver/ie/service.rb +5 -9
- data/lib/selenium/webdriver/remote.rb +16 -10
- data/lib/selenium/webdriver/remote/bridge.rb +38 -42
- data/lib/selenium/webdriver/remote/capabilities.rb +25 -7
- data/lib/selenium/webdriver/remote/driver.rb +6 -13
- data/lib/selenium/webdriver/remote/http/default.rb +10 -6
- data/lib/selenium/webdriver/remote/http/persistent.rb +5 -6
- data/lib/selenium/webdriver/safari.rb +16 -8
- data/lib/selenium/webdriver/safari/bridge.rb +4 -4
- data/lib/selenium/webdriver/safari/driver.rb +3 -30
- data/lib/selenium/webdriver/safari/options.rb +18 -19
- data/lib/selenium/webdriver/safari/service.rb +0 -4
- data/lib/selenium/webdriver/support.rb +1 -0
- data/lib/selenium/webdriver/support/color.rb +2 -2
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +1 -1
- data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
- data/lib/selenium/webdriver/version.rb +1 -1
- data/selenium-webdriver.gemspec +7 -6
- metadata +225 -21
- data/lib/selenium/webdriver/firefox/binary.rb +0 -110
- data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
@@ -0,0 +1,39 @@
|
|
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 DriverExtensions
|
23
|
+
module HasDevTools
|
24
|
+
|
25
|
+
#
|
26
|
+
# Retrieves connection to DevTools.
|
27
|
+
#
|
28
|
+
# @return [DevTools]
|
29
|
+
#
|
30
|
+
|
31
|
+
def devtools
|
32
|
+
version = Integer(capabilities.browser_version.split('.').first)
|
33
|
+
@devtools ||= DevTools.new(url: debugger_address, version: version)
|
34
|
+
end
|
35
|
+
|
36
|
+
end # HasDevTools
|
37
|
+
end # DriverExtensions
|
38
|
+
end # WebDriver
|
39
|
+
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
|
+
module Selenium
|
21
|
+
module WebDriver
|
22
|
+
module DriverExtensions
|
23
|
+
module HasLogEvents
|
24
|
+
include Atoms
|
25
|
+
|
26
|
+
KINDS = %i[console exception mutation].freeze
|
27
|
+
|
28
|
+
#
|
29
|
+
# Registers listener to be called whenever browser receives
|
30
|
+
# a new Console API message such as console.log() or an unhandled
|
31
|
+
# exception.
|
32
|
+
#
|
33
|
+
# This currently relies on DevTools so is only supported in
|
34
|
+
# Chromium browsers.
|
35
|
+
#
|
36
|
+
# @example Collect console messages
|
37
|
+
# logs = []
|
38
|
+
# driver.on_log_event(:console) do |event|
|
39
|
+
# logs.push(event)
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# @example Collect JavaScript exceptions
|
43
|
+
# exceptions = []
|
44
|
+
# driver.on_log_event(:exception) do |event|
|
45
|
+
# exceptions.push(event)
|
46
|
+
# end
|
47
|
+
#
|
48
|
+
# @example Collect DOM mutations
|
49
|
+
# mutations = []
|
50
|
+
# driver.on_log_event(:mutation) do |event|
|
51
|
+
# mutations.push(event)
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# @param [Symbol] kind :console, :exception or :mutation
|
55
|
+
# @param [#call] block which is called when event happens
|
56
|
+
# @yieldparam [DevTools::ConsoleEvent, DevTools::ExceptionEvent, DevTools::MutationEvent]
|
57
|
+
#
|
58
|
+
|
59
|
+
def on_log_event(kind, &block)
|
60
|
+
raise Error::WebDriverError, "Don't know how to handle #{kind} events" unless KINDS.include?(kind)
|
61
|
+
|
62
|
+
enabled = log_listeners[kind].any?
|
63
|
+
log_listeners[kind] << block
|
64
|
+
return if enabled
|
65
|
+
|
66
|
+
devtools.runtime.enable
|
67
|
+
__send__("log_#{kind}_events")
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def log_listeners
|
73
|
+
@log_listeners ||= Hash.new { |listeners, kind| listeners[kind] = [] }
|
74
|
+
end
|
75
|
+
|
76
|
+
def log_console_events
|
77
|
+
devtools.runtime.on(:console_api_called) do |params|
|
78
|
+
event = DevTools::ConsoleEvent.new(
|
79
|
+
type: params['type'],
|
80
|
+
timestamp: params['timestamp'],
|
81
|
+
args: params['args']
|
82
|
+
)
|
83
|
+
|
84
|
+
log_listeners[:console].each do |listener|
|
85
|
+
listener.call(event)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def log_exception_events
|
91
|
+
devtools.runtime.on(:exception_thrown) do |params|
|
92
|
+
event = DevTools::ExceptionEvent.new(
|
93
|
+
description: params.dig('exceptionDetails', 'exception', 'description'),
|
94
|
+
timestamp: params['timestamp'],
|
95
|
+
stacktrace: params.dig('exceptionDetails', 'stackTrace', 'callFrames')
|
96
|
+
)
|
97
|
+
|
98
|
+
log_listeners[:exception].each do |listener|
|
99
|
+
listener.call(event)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
def log_mutation_events
|
105
|
+
devtools.page.enable
|
106
|
+
|
107
|
+
devtools.runtime.add_binding(name: '__webdriver_attribute')
|
108
|
+
execute_script(mutation_listener)
|
109
|
+
script = devtools.page.add_script_to_evaluate_on_new_document(source: mutation_listener)
|
110
|
+
pinned_scripts[mutation_listener] = script['identifier']
|
111
|
+
|
112
|
+
devtools.runtime.on(:binding_called, &method(:log_mutation_event))
|
113
|
+
end
|
114
|
+
|
115
|
+
def log_mutation_event(params)
|
116
|
+
payload = JSON.parse(params['payload'])
|
117
|
+
elements = find_elements(css: "*[data-__webdriver_id='#{payload['target']}']")
|
118
|
+
return if elements.empty?
|
119
|
+
|
120
|
+
event = DevTools::MutationEvent.new(
|
121
|
+
element: elements.first,
|
122
|
+
attribute_name: payload['name'],
|
123
|
+
current_value: payload['value'],
|
124
|
+
old_value: payload['oldValue']
|
125
|
+
)
|
126
|
+
|
127
|
+
log_listeners[:mutation].each do |log_listener|
|
128
|
+
log_listener.call(event)
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def mutation_listener
|
133
|
+
@mutation_listener ||= read_atom(:mutationListener)
|
134
|
+
end
|
135
|
+
|
136
|
+
def pinned_scripts
|
137
|
+
@pinned_scripts ||= {}
|
138
|
+
end
|
139
|
+
|
140
|
+
end # HasLogEvents
|
141
|
+
end # DriverExtensions
|
142
|
+
end # WebDriver
|
143
|
+
end # Selenium
|
@@ -35,7 +35,8 @@ module Selenium
|
|
35
35
|
extension = File.extname(png_path).downcase
|
36
36
|
if extension != '.png'
|
37
37
|
WebDriver.logger.warn "name used for saved screenshot does not match file type. "\
|
38
|
-
"It should end with .png extension"
|
38
|
+
"It should end with .png extension",
|
39
|
+
id: :screenshot
|
39
40
|
end
|
40
41
|
File.open(png_path, 'wb') { |f| f << screenshot_as(:png) }
|
41
42
|
end
|
@@ -23,6 +23,7 @@ module Selenium
|
|
23
23
|
ELEMENT_KEY = 'element-6066-11e4-a52e-4f735466cecf'
|
24
24
|
|
25
25
|
include SearchContext
|
26
|
+
include TakesScreenshot
|
26
27
|
|
27
28
|
#
|
28
29
|
# Creates a new Element
|
@@ -327,6 +328,10 @@ module Selenium
|
|
327
328
|
|
328
329
|
tn == 'option' || (tn == 'input' && %w[radio checkbox].include?(type))
|
329
330
|
end
|
331
|
+
|
332
|
+
def screenshot
|
333
|
+
bridge.element_screenshot(self)
|
334
|
+
end
|
330
335
|
end # Element
|
331
336
|
end # WebDriver
|
332
337
|
end # Selenium
|
@@ -40,13 +40,17 @@ module Selenium
|
|
40
40
|
:close,
|
41
41
|
:debug, :debug?,
|
42
42
|
:info, :info?,
|
43
|
-
:warn
|
43
|
+
:warn?,
|
44
44
|
:error, :error?,
|
45
45
|
:fatal, :fatal?,
|
46
46
|
:level, :level=
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
#
|
49
|
+
# @param [String] progname Allow child projects to use Selenium's Logger pattern
|
50
|
+
#
|
51
|
+
def initialize(progname = 'Selenium')
|
52
|
+
@logger = create_logger(progname)
|
53
|
+
@ignored = []
|
50
54
|
end
|
51
55
|
|
52
56
|
#
|
@@ -73,28 +77,60 @@ module Selenium
|
|
73
77
|
@logger.instance_variable_get(:@logdev).dev
|
74
78
|
end
|
75
79
|
|
80
|
+
#
|
81
|
+
# Will not log the provided ID.
|
82
|
+
#
|
83
|
+
# @param [Array, Symbol] id
|
84
|
+
#
|
85
|
+
def ignore(id)
|
86
|
+
Array(id).each { |ignore| @ignored << ignore }
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# Overrides default #warn to skip ignored messages by provided id
|
91
|
+
#
|
92
|
+
# @param [String] message
|
93
|
+
# @param [Symbol, Array<Sybmol>] id
|
94
|
+
# @yield see #deprecate
|
95
|
+
#
|
96
|
+
def warn(message, id: [])
|
97
|
+
id = Array(id)
|
98
|
+
return if (@ignored & id).any?
|
99
|
+
|
100
|
+
msg = id.empty? ? message : "[#{id.map(&:inspect).join(', ')}] #{message} "
|
101
|
+
msg += " #{yield}" if block_given?
|
102
|
+
|
103
|
+
@logger.warn { msg }
|
104
|
+
end
|
105
|
+
|
76
106
|
#
|
77
107
|
# Marks code as deprecated with/without replacement.
|
78
108
|
#
|
79
109
|
# @param [String] old
|
80
110
|
# @param [String, nil] new
|
111
|
+
# @param [Symbol, Array<Sybmol>] id
|
112
|
+
# @yield appends additional message to end of provided template
|
81
113
|
#
|
82
|
-
def deprecate(old, new = nil)
|
83
|
-
|
114
|
+
def deprecate(old, new = nil, id: [], &block)
|
115
|
+
id = Array(id)
|
116
|
+
return if @ignored.include?(:deprecations) || (@ignored & id).any?
|
117
|
+
|
118
|
+
ids = id.empty? ? '' : "[#{id.map(&:inspect).join(', ')}] "
|
119
|
+
|
120
|
+
message = +"[DEPRECATION] #{ids}#{old} is deprecated"
|
84
121
|
message << if new
|
85
122
|
". Use #{new} instead."
|
86
123
|
else
|
87
|
-
' and will be removed in
|
124
|
+
' and will be removed in a future release.'
|
88
125
|
end
|
89
|
-
|
90
|
-
warn message
|
126
|
+
warn message, &block
|
91
127
|
end
|
92
128
|
|
93
129
|
private
|
94
130
|
|
95
|
-
def create_logger(
|
96
|
-
logger = ::Logger.new(
|
97
|
-
logger.progname =
|
131
|
+
def create_logger(name)
|
132
|
+
logger = ::Logger.new($stdout)
|
133
|
+
logger.progname = name
|
98
134
|
logger.level = default_level
|
99
135
|
logger.formatter = proc do |severity, time, progname, msg|
|
100
136
|
"#{time.strftime('%F %T')} #{severity} #{progname} #{msg}\n"
|
@@ -104,11 +140,7 @@ module Selenium
|
|
104
140
|
end
|
105
141
|
|
106
142
|
def default_level
|
107
|
-
|
108
|
-
:debug
|
109
|
-
else
|
110
|
-
:warn
|
111
|
-
end
|
143
|
+
$DEBUG || ENV.key?('DEBUG') ? :debug : :warn
|
112
144
|
end
|
113
145
|
end # Logger
|
114
146
|
end # WebDriver
|
@@ -36,6 +36,7 @@ module Selenium
|
|
36
36
|
# @option opts [String] :value A value
|
37
37
|
# @option opts [String] :path ('/') A path
|
38
38
|
# @option opts [String] :secure (false) A boolean
|
39
|
+
# @option opts [String] :same_site (Strict or Lax) currently supported only in chrome 80+ versions
|
39
40
|
# @option opts [Time,DateTime,Numeric,nil] :expires (nil) Expiry date, either as a Time, DateTime, or seconds since epoch.
|
40
41
|
#
|
41
42
|
# @raise [ArgumentError] if :name or :value is not specified
|
@@ -48,6 +49,9 @@ module Selenium
|
|
48
49
|
opts[:path] ||= '/'
|
49
50
|
opts[:secure] ||= false
|
50
51
|
|
52
|
+
same_site = opts.delete(:same_site)
|
53
|
+
opts[:sameSite] = same_site if same_site
|
54
|
+
|
51
55
|
obj = opts.delete(:expires)
|
52
56
|
opts[:expiry] = seconds_from(obj).to_i if obj
|
53
57
|
|
@@ -169,6 +173,7 @@ module Selenium
|
|
169
173
|
path: cookie['path'],
|
170
174
|
domain: cookie['domain'] && strip_port(cookie['domain']),
|
171
175
|
expires: cookie['expiry'] && datetime_at(cookie['expiry']),
|
176
|
+
same_site: cookie['sameSite'],
|
172
177
|
secure: cookie['secure']
|
173
178
|
}
|
174
179
|
end
|
@@ -0,0 +1,116 @@
|
|
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 Options
|
23
|
+
W3C_OPTIONS = %i[browser_name browser_version platform_name accept_insecure_certs page_load_strategy proxy
|
24
|
+
set_window_rect timeouts unhandled_prompt_behavior strict_file_interactability].freeze
|
25
|
+
|
26
|
+
W3C_OPTIONS.each do |key|
|
27
|
+
define_method key do
|
28
|
+
@options[key]
|
29
|
+
end
|
30
|
+
|
31
|
+
define_method "#{key}=" do |value|
|
32
|
+
@options[key] = value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
attr_accessor :options
|
37
|
+
|
38
|
+
def initialize(options: nil, **opts)
|
39
|
+
@options = if options
|
40
|
+
WebDriver.logger.deprecate(":options as keyword for initializing #{self.class}",
|
41
|
+
"custom values directly in #new constructor",
|
42
|
+
id: :options_options)
|
43
|
+
opts.merge(options)
|
44
|
+
else
|
45
|
+
opts
|
46
|
+
end
|
47
|
+
@options[:browser_name] = self.class::BROWSER
|
48
|
+
end
|
49
|
+
|
50
|
+
#
|
51
|
+
# Add a new option not yet handled by bindings.
|
52
|
+
#
|
53
|
+
# @example Leave Chrome open when chromedriver is killed
|
54
|
+
# options = Selenium::WebDriver::Chrome::Options.new
|
55
|
+
# options.add_option(:detach, true)
|
56
|
+
#
|
57
|
+
# @param [String, Symbol] name Name of the option
|
58
|
+
# @param [Boolean, String, Integer] value Value of the option
|
59
|
+
#
|
60
|
+
|
61
|
+
def add_option(name, value)
|
62
|
+
@options[name] = value
|
63
|
+
end
|
64
|
+
|
65
|
+
#
|
66
|
+
# @api private
|
67
|
+
#
|
68
|
+
|
69
|
+
def as_json(*)
|
70
|
+
options = @options.dup
|
71
|
+
|
72
|
+
w3c_options = options.select { |key, _val| W3C_OPTIONS.include?(key) }
|
73
|
+
options.delete_if { |key, _val| W3C_OPTIONS.include?(key) }
|
74
|
+
|
75
|
+
self.class::CAPABILITIES.each do |capability_alias, capability_name|
|
76
|
+
capability_value = options.delete(capability_alias)
|
77
|
+
options[capability_name] = capability_value unless capability_value.nil?
|
78
|
+
end
|
79
|
+
browser_options = defined?(self.class::KEY) ? {self.class::KEY => options} : options
|
80
|
+
|
81
|
+
process_browser_options(browser_options) if private_methods(false).include?(:process_browser_options)
|
82
|
+
generate_as_json(w3c_options.merge(browser_options))
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def generate_as_json(value, camelize_keys: true)
|
88
|
+
if value.is_a?(Hash)
|
89
|
+
value.each_with_object({}) do |(key, val), hash|
|
90
|
+
hash[convert_json_key(key, camelize: camelize_keys)] = generate_as_json(val, camelize_keys: camelize_keys)
|
91
|
+
end
|
92
|
+
elsif value.respond_to?(:as_json)
|
93
|
+
value.as_json
|
94
|
+
elsif value.is_a?(Array)
|
95
|
+
value.map { |val| generate_as_json(val, camelize_keys: camelize_keys) }
|
96
|
+
elsif value.is_a?(Symbol)
|
97
|
+
value.to_s
|
98
|
+
else
|
99
|
+
value
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def convert_json_key(key, camelize: true)
|
104
|
+
key = key.to_s if key.is_a?(Symbol)
|
105
|
+
key = camel_case(key) if camelize
|
106
|
+
return key if key.is_a?(String)
|
107
|
+
|
108
|
+
raise TypeError, "expected String or Symbol, got #{key.inspect}:#{key.class}"
|
109
|
+
end
|
110
|
+
|
111
|
+
def camel_case(str)
|
112
|
+
str.gsub(/_([a-z])/) { Regexp.last_match(1).upcase }
|
113
|
+
end
|
114
|
+
end # Options
|
115
|
+
end # WebDriver
|
116
|
+
end # Selenium
|