selenium-webdriver 4.0.0.alpha6 → 4.0.0.beta4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES +137 -4
- data/Gemfile +3 -1
- data/LICENSE +1 -1
- data/NOTICE +2 -0
- data/README.md +4 -5
- data/lib/selenium/server.rb +18 -26
- data/lib/selenium/webdriver.rb +1 -4
- data/lib/selenium/webdriver/atoms/findElements.js +93 -93
- data/lib/selenium/webdriver/atoms/getAttribute.js +75 -59
- data/lib/selenium/webdriver/atoms/isDisplayed.js +72 -72
- data/lib/selenium/webdriver/atoms/mutationListener.js +55 -0
- data/lib/selenium/webdriver/chrome.rb +1 -1
- data/lib/selenium/webdriver/chrome/driver.rb +25 -10
- data/lib/selenium/webdriver/chrome/{bridge.rb → features.rb} +3 -3
- data/lib/selenium/webdriver/chrome/options.rb +51 -39
- data/lib/selenium/webdriver/chrome/profile.rb +6 -3
- data/lib/selenium/webdriver/chrome/service.rb +4 -2
- data/lib/selenium/webdriver/common.rb +8 -2
- data/lib/selenium/webdriver/common/driver.rb +36 -8
- data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +43 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +89 -0
- data/lib/selenium/webdriver/{edge_html/driver.rb → common/driver_extensions/has_cdp.rb} +12 -13
- data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +6 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +5 -8
- data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +149 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_logs.rb +30 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +6 -27
- data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +67 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +1 -0
- data/lib/selenium/webdriver/common/driver_extensions/{rotatable.rb → prints_page.rb} +18 -20
- data/lib/selenium/webdriver/common/element.rb +66 -12
- data/lib/selenium/webdriver/common/interactions/interaction.rb +4 -1
- data/lib/selenium/webdriver/common/logger.rb +5 -2
- data/lib/selenium/webdriver/common/manager.rb +6 -1
- data/lib/selenium/webdriver/common/options.rb +76 -14
- data/lib/selenium/webdriver/common/platform.rb +3 -1
- data/lib/selenium/webdriver/common/proxy.rb +6 -3
- data/lib/selenium/webdriver/common/search_context.rb +4 -1
- data/lib/selenium/webdriver/common/service.rb +1 -8
- data/lib/selenium/webdriver/common/service_manager.rb +1 -1
- data/lib/selenium/webdriver/common/socket_poller.rb +19 -30
- data/lib/selenium/webdriver/common/takes_screenshot.rb +66 -0
- data/lib/selenium/webdriver/common/target_locator.rb +4 -4
- data/lib/selenium/webdriver/devtools.rb +44 -18
- data/lib/selenium/webdriver/devtools/console_event.rb +38 -0
- data/lib/selenium/webdriver/devtools/exception_event.rb +36 -0
- data/lib/selenium/webdriver/devtools/mutation_event.rb +37 -0
- data/lib/selenium/webdriver/devtools/{console.rb → request.rb} +22 -22
- data/lib/selenium/webdriver/edge.rb +7 -29
- data/lib/selenium/webdriver/{edge_chrome → edge}/driver.rb +8 -6
- data/lib/selenium/webdriver/{edge_chrome/bridge.rb → edge/features.rb} +9 -7
- data/lib/selenium/webdriver/{edge_chrome → edge}/options.rb +11 -4
- data/lib/selenium/webdriver/{edge_chrome → edge}/profile.rb +2 -2
- data/lib/selenium/webdriver/{edge_chrome → edge}/service.rb +2 -2
- data/lib/selenium/webdriver/firefox.rb +5 -1
- data/lib/selenium/webdriver/firefox/driver.rb +18 -5
- data/lib/selenium/webdriver/firefox/{bridge.rb → features.rb} +9 -4
- data/lib/selenium/webdriver/firefox/options.rb +20 -21
- data/lib/selenium/webdriver/firefox/profile.rb +12 -2
- data/lib/selenium/webdriver/firefox/service.rb +1 -1
- data/lib/selenium/webdriver/ie/driver.rb +1 -2
- data/lib/selenium/webdriver/ie/options.rb +1 -11
- data/lib/selenium/webdriver/ie/service.rb +4 -2
- data/lib/selenium/webdriver/remote/bridge.rb +48 -30
- data/lib/selenium/webdriver/remote/capabilities.rb +105 -64
- data/lib/selenium/webdriver/remote/commands.rb +3 -0
- data/lib/selenium/webdriver/remote/driver.rb +10 -3
- data/lib/selenium/webdriver/remote/http/common.rb +0 -5
- data/lib/selenium/webdriver/remote/http/default.rb +8 -7
- data/lib/selenium/webdriver/remote/http/persistent.rb +6 -0
- data/lib/selenium/webdriver/safari.rb +8 -1
- data/lib/selenium/webdriver/safari/driver.rb +3 -8
- data/lib/selenium/webdriver/safari/{bridge.rb → features.rb} +3 -3
- data/lib/selenium/webdriver/safari/options.rb +0 -25
- data/lib/selenium/webdriver/support/block_event_listener.rb +1 -1
- data/lib/selenium/webdriver/support/cdp/domain.rb.erb +63 -0
- data/lib/selenium/webdriver/support/cdp_client_generator.rb +44 -13
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +1 -1
- data/lib/selenium/webdriver/support/guards.rb +95 -0
- data/lib/selenium/webdriver/support/guards/guard.rb +89 -0
- data/lib/selenium/webdriver/support/guards/guard_condition.rb +52 -0
- data/lib/selenium/webdriver/support/select.rb +2 -2
- data/lib/selenium/webdriver/version.rb +1 -1
- data/selenium-webdriver.gemspec +26 -12
- metadata +91 -108
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +0 -65
- data/lib/selenium/webdriver/devtools/accessibility.rb +0 -62
- data/lib/selenium/webdriver/devtools/animation.rb +0 -98
- data/lib/selenium/webdriver/devtools/application_cache.rb +0 -64
- data/lib/selenium/webdriver/devtools/audits.rb +0 -61
- data/lib/selenium/webdriver/devtools/background_service.rb +0 -67
- data/lib/selenium/webdriver/devtools/browser.rb +0 -123
- data/lib/selenium/webdriver/devtools/cache_storage.rb +0 -73
- data/lib/selenium/webdriver/devtools/cast.rb +0 -70
- data/lib/selenium/webdriver/devtools/css.rb +0 -165
- data/lib/selenium/webdriver/devtools/database.rb +0 -64
- data/lib/selenium/webdriver/devtools/debugger.rb +0 -229
- data/lib/selenium/webdriver/devtools/device_orientation.rb +0 -53
- data/lib/selenium/webdriver/devtools/dom.rb +0 -320
- data/lib/selenium/webdriver/devtools/domdebugger.rb +0 -93
- data/lib/selenium/webdriver/devtools/domsnapshot.rb +0 -65
- data/lib/selenium/webdriver/devtools/domstorage.rb +0 -79
- data/lib/selenium/webdriver/devtools/emulation.rb +0 -180
- data/lib/selenium/webdriver/devtools/fetch.rb +0 -97
- data/lib/selenium/webdriver/devtools/headless_experimental.rb +0 -61
- data/lib/selenium/webdriver/devtools/heap_profiler.rb +0 -107
- data/lib/selenium/webdriver/devtools/indexed_db.rb +0 -100
- data/lib/selenium/webdriver/devtools/input.rb +0 -140
- data/lib/selenium/webdriver/devtools/inspector.rb +0 -55
- data/lib/selenium/webdriver/devtools/io.rb +0 -59
- data/lib/selenium/webdriver/devtools/layer_tree.rb +0 -95
- data/lib/selenium/webdriver/devtools/log.rb +0 -66
- data/lib/selenium/webdriver/devtools/media.rb +0 -57
- data/lib/selenium/webdriver/devtools/memory.rb +0 -86
- data/lib/selenium/webdriver/devtools/network.rb +0 -228
- data/lib/selenium/webdriver/devtools/overlay.rb +0 -157
- data/lib/selenium/webdriver/devtools/page.rb +0 -374
- data/lib/selenium/webdriver/devtools/performance.rb +0 -63
- data/lib/selenium/webdriver/devtools/profiler.rb +0 -111
- data/lib/selenium/webdriver/devtools/runtime.rb +0 -193
- data/lib/selenium/webdriver/devtools/schema.rb +0 -46
- data/lib/selenium/webdriver/devtools/security.rb +0 -71
- data/lib/selenium/webdriver/devtools/service_worker.rb +0 -116
- data/lib/selenium/webdriver/devtools/storage.rb +0 -95
- data/lib/selenium/webdriver/devtools/system_info.rb +0 -50
- data/lib/selenium/webdriver/devtools/target.rb +0 -141
- data/lib/selenium/webdriver/devtools/tethering.rb +0 -55
- data/lib/selenium/webdriver/devtools/tracing.rb +0 -76
- data/lib/selenium/webdriver/devtools/web_audio.rb +0 -70
- data/lib/selenium/webdriver/devtools/web_authn.rb +0 -94
- data/lib/selenium/webdriver/edge_html/options.rb +0 -84
- data/lib/selenium/webdriver/edge_html/service.rb +0 -47
|
@@ -82,6 +82,8 @@ module Selenium
|
|
|
82
82
|
get_element_attribute: [:get, 'session/:session_id/element/:id/attribute/:name'],
|
|
83
83
|
get_element_property: [:get, 'session/:session_id/element/:id/property/:name'],
|
|
84
84
|
get_element_css_value: [:get, 'session/:session_id/element/:id/css/:property_name'],
|
|
85
|
+
get_element_aria_role: [:get, 'session/:session_id/element/:id/computedrole'],
|
|
86
|
+
get_element_aria_label: [:get, 'session/:session_id/element/:id/computedlabel'],
|
|
85
87
|
get_element_text: [:get, 'session/:session_id/element/:id/text'],
|
|
86
88
|
get_element_tag_name: [:get, 'session/:session_id/element/:id/name'],
|
|
87
89
|
get_element_rect: [:get, 'session/:session_id/element/:id/rect'],
|
|
@@ -117,6 +119,7 @@ module Selenium
|
|
|
117
119
|
|
|
118
120
|
actions: [:post, 'session/:session_id/actions'],
|
|
119
121
|
release_actions: [:delete, 'session/:session_id/actions'],
|
|
122
|
+
print_page: [:post, 'session/:session_id/print'],
|
|
120
123
|
|
|
121
124
|
#
|
|
122
125
|
# Element Operations
|
|
@@ -28,11 +28,8 @@ module Selenium
|
|
|
28
28
|
|
|
29
29
|
class Driver < WebDriver::Driver
|
|
30
30
|
include DriverExtensions::UploadsFiles
|
|
31
|
-
include DriverExtensions::TakesScreenshot
|
|
32
31
|
include DriverExtensions::HasSessionId
|
|
33
|
-
include DriverExtensions::Rotatable
|
|
34
32
|
include DriverExtensions::HasRemoteStatus
|
|
35
|
-
include DriverExtensions::HasWebStorage
|
|
36
33
|
|
|
37
34
|
def initialize(bridge: nil, listener: nil, **opts)
|
|
38
35
|
desired_capabilities = opts[:desired_capabilities]
|
|
@@ -46,6 +43,16 @@ module Selenium
|
|
|
46
43
|
opts[:url] ||= "http://#{Platform.localhost}:4444/wd/hub"
|
|
47
44
|
super
|
|
48
45
|
end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def devtools_url
|
|
50
|
+
capabilities['se:cdp']
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def devtools_version
|
|
54
|
+
capabilities['se:cdpVersion'].split('.').first
|
|
55
|
+
end
|
|
49
56
|
end # Driver
|
|
50
57
|
end # Remote
|
|
51
58
|
end # WebDriver
|
|
@@ -28,8 +28,7 @@ module Selenium
|
|
|
28
28
|
class Default < Common
|
|
29
29
|
attr_writer :proxy
|
|
30
30
|
|
|
31
|
-
attr_accessor :open_timeout
|
|
32
|
-
attr_accessor :read_timeout
|
|
31
|
+
attr_accessor :open_timeout, :read_timeout
|
|
33
32
|
|
|
34
33
|
# Initializes object.
|
|
35
34
|
# Warning: Setting {#open_timeout} to non-nil values will cause a separate thread to spawn.
|
|
@@ -39,6 +38,7 @@ module Selenium
|
|
|
39
38
|
def initialize(open_timeout: nil, read_timeout: nil)
|
|
40
39
|
@open_timeout = open_timeout
|
|
41
40
|
@read_timeout = read_timeout
|
|
41
|
+
super()
|
|
42
42
|
end
|
|
43
43
|
|
|
44
44
|
def close
|
|
@@ -55,8 +55,7 @@ module Selenium
|
|
|
55
55
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
http.open_timeout = open_timeout
|
|
58
|
+
http.open_timeout = open_timeout if open_timeout
|
|
60
59
|
http.read_timeout = read_timeout if read_timeout
|
|
61
60
|
|
|
62
61
|
start(http)
|
|
@@ -128,12 +127,14 @@ module Selenium
|
|
|
128
127
|
def new_http_client
|
|
129
128
|
if use_proxy?
|
|
130
129
|
url = @proxy.http
|
|
131
|
-
|
|
130
|
+
unless proxy.respond_to?(:http) && url
|
|
131
|
+
raise Error::WebDriverError,
|
|
132
|
+
"expected HTTP proxy, got #{@proxy.inspect}"
|
|
133
|
+
end
|
|
132
134
|
|
|
133
135
|
proxy = URI.parse(url)
|
|
134
136
|
|
|
135
|
-
|
|
136
|
-
clazz.new(server_url.host, server_url.port)
|
|
137
|
+
Net::HTTP.new(server_url.host, server_url.port, proxy.host, proxy.port, proxy.user, proxy.password)
|
|
137
138
|
else
|
|
138
139
|
Net::HTTP.new server_url.host, server_url.port
|
|
139
140
|
end
|
|
@@ -25,6 +25,12 @@ module Selenium
|
|
|
25
25
|
module Http
|
|
26
26
|
# @api private
|
|
27
27
|
class Persistent < Default
|
|
28
|
+
def initialize(open_timeout: nil, read_timeout: nil)
|
|
29
|
+
WebDriver.logger.deprecate("Selenium::WebDriver::Remote::Http::Persistent",
|
|
30
|
+
id: :http_persistent) { "The default HTTP client now uses persistence." }
|
|
31
|
+
super
|
|
32
|
+
end
|
|
33
|
+
|
|
28
34
|
def close
|
|
29
35
|
@http&.shutdown
|
|
30
36
|
end
|
|
@@ -20,18 +20,25 @@
|
|
|
20
20
|
module Selenium
|
|
21
21
|
module WebDriver
|
|
22
22
|
module Safari
|
|
23
|
-
autoload :
|
|
23
|
+
autoload :Features, 'selenium/webdriver/safari/features'
|
|
24
24
|
autoload :Driver, 'selenium/webdriver/safari/driver'
|
|
25
25
|
autoload :Options, 'selenium/webdriver/safari/options'
|
|
26
26
|
autoload :Service, 'selenium/webdriver/safari/service'
|
|
27
27
|
|
|
28
28
|
class << self
|
|
29
|
+
attr_accessor :use_technology_preview
|
|
30
|
+
|
|
29
31
|
def technology_preview
|
|
30
32
|
"/Applications/Safari\ Technology\ Preview.app/Contents/MacOS/safaridriver"
|
|
31
33
|
end
|
|
32
34
|
|
|
33
35
|
def technology_preview!
|
|
34
36
|
Service.driver_path = technology_preview
|
|
37
|
+
@use_technology_preview = true
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def technology_preview?
|
|
41
|
+
use_technology_preview
|
|
35
42
|
end
|
|
36
43
|
|
|
37
44
|
def path=(path)
|
|
@@ -27,18 +27,13 @@ module Selenium
|
|
|
27
27
|
#
|
|
28
28
|
|
|
29
29
|
class Driver < WebDriver::Driver
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
include DriverExtensions::TakesScreenshot
|
|
30
|
+
EXTENSIONS = [DriverExtensions::HasDebugger,
|
|
31
|
+
DriverExtensions::HasPermissions,
|
|
32
|
+
DriverExtensions::HasWebStorage].freeze
|
|
34
33
|
|
|
35
34
|
def browser
|
|
36
35
|
:safari
|
|
37
36
|
end
|
|
38
|
-
|
|
39
|
-
def bridge_class
|
|
40
|
-
Bridge
|
|
41
|
-
end
|
|
42
37
|
end # Driver
|
|
43
38
|
end # Safari
|
|
44
39
|
end # WebDriver
|
|
@@ -20,17 +20,17 @@
|
|
|
20
20
|
module Selenium
|
|
21
21
|
module WebDriver
|
|
22
22
|
module Safari
|
|
23
|
-
|
|
23
|
+
module Features
|
|
24
24
|
|
|
25
25
|
# https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/WebDriverEndpointDoc/Commands/Commands.html
|
|
26
|
-
|
|
26
|
+
SAFARI_COMMANDS = {
|
|
27
27
|
get_permissions: [:get, 'session/:session_id/apple/permissions'],
|
|
28
28
|
set_permissions: [:post, 'session/:session_id/apple/permissions'],
|
|
29
29
|
attach_debugger: [:post, 'session/:session_id/apple/attach_debugger']
|
|
30
30
|
}.freeze
|
|
31
31
|
|
|
32
32
|
def commands(command)
|
|
33
|
-
|
|
33
|
+
SAFARI_COMMANDS[command] || self.class::COMMANDS[command]
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
def permissions
|
|
@@ -28,31 +28,6 @@ module Selenium
|
|
|
28
28
|
automatic_profiling: 'safari:automaticProfiling'}.freeze
|
|
29
29
|
BROWSER = 'safari'
|
|
30
30
|
|
|
31
|
-
CAPABILITIES.each_key do |key|
|
|
32
|
-
define_method key do
|
|
33
|
-
@options[key]
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
define_method "#{key}=" do |value|
|
|
37
|
-
@options[key] = value
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
#
|
|
42
|
-
# Create a new Options instance for W3C-capable versions of Safari.
|
|
43
|
-
#
|
|
44
|
-
# @example
|
|
45
|
-
# options = Selenium::WebDriver::Safari::Options.new(automatic_inspection: true)
|
|
46
|
-
# driver = Selenium::WebDriver.for :safari, options: options
|
|
47
|
-
#
|
|
48
|
-
# @param [Hash] opts the pre-defined options to create the Safari::Options with
|
|
49
|
-
# @option opts [Boolean] :automatic_inspection Preloads Web Inspector and JavaScript debugger. Default is false
|
|
50
|
-
# @option opts [Boolean] :automatic_profiling Preloads Web Inspector and starts a timeline recording. Default is false
|
|
51
|
-
#
|
|
52
|
-
|
|
53
|
-
def initialize(**opts)
|
|
54
|
-
super
|
|
55
|
-
end
|
|
56
31
|
end # Options
|
|
57
32
|
end # Safari
|
|
58
33
|
end # WebDriver
|
|
@@ -25,7 +25,7 @@ module Selenium
|
|
|
25
25
|
@callback = callback
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
-
def method_missing(meth, *args) # rubocop:disable Style/
|
|
28
|
+
def method_missing(meth, *args) # rubocop:disable Style/MissingRespondToMissing
|
|
29
29
|
@callback.call meth, *args
|
|
30
30
|
end
|
|
31
31
|
end # BlockEventListener
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
|
5
|
+
# distributed with this work for additional information
|
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
|
8
|
+
# "License"); you may not use this file except in compliance
|
|
9
|
+
# with the License. You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
|
14
|
+
# software distributed under the License is distributed on an
|
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
# KIND, either express or implied. See the License for the
|
|
17
|
+
# specific language governing permissions and limitations
|
|
18
|
+
# under the License.
|
|
19
|
+
|
|
20
|
+
# This file is automatically generated. Any changes will be lost!
|
|
21
|
+
module Selenium
|
|
22
|
+
module DevTools
|
|
23
|
+
module <%= version %>
|
|
24
|
+
class <%= domain[:domain] %>
|
|
25
|
+
<% if domain[:events] %>
|
|
26
|
+
EVENTS = {
|
|
27
|
+
<% domain[:events].each do |event| %>
|
|
28
|
+
<%= h.snake_case(event[:name]) %>: '<%= event[:name] %>',
|
|
29
|
+
<% end %>
|
|
30
|
+
}.freeze
|
|
31
|
+
<% end %>
|
|
32
|
+
|
|
33
|
+
def initialize(devtools)
|
|
34
|
+
@devtools = devtools
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def on(event, &block)
|
|
38
|
+
event = EVENTS[event] if event.is_a?(Symbol)
|
|
39
|
+
@devtools.callbacks["<%= domain[:domain] %>.#{event}"] << block
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
<% domain[:commands].each do |command| %>
|
|
43
|
+
<% if command[:parameters] %>
|
|
44
|
+
def <%= h.snake_case(command[:name]) %>(<%= h.kwargs(command[:parameters]) %>)
|
|
45
|
+
<% else %>
|
|
46
|
+
def <%= h.snake_case(command[:name]) %>
|
|
47
|
+
<% end %>
|
|
48
|
+
<% if command[:parameters] %>
|
|
49
|
+
@devtools.send_cmd('<%= domain[:domain] %>.<%= command[:name] %>',
|
|
50
|
+
<% until command[:parameters].empty? %>
|
|
51
|
+
<% parameter = command[:parameters].shift %>
|
|
52
|
+
<%= parameter[:name] %>: <%= h.snake_case(parameter[:name]) %><%= command[:parameters].empty? ? ')' : ',' %>
|
|
53
|
+
<% end %>
|
|
54
|
+
<% else %>
|
|
55
|
+
@devtools.send_cmd('<%= domain[:domain] %>.<%= command[:name] %>')
|
|
56
|
+
<% end %>
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
<% end %>
|
|
60
|
+
end # <%= domain[:domain] %>
|
|
61
|
+
end # <%= version %>
|
|
62
|
+
end # DevTools
|
|
63
|
+
end # Selenium
|
|
@@ -18,38 +18,48 @@
|
|
|
18
18
|
# under the License.
|
|
19
19
|
|
|
20
20
|
require 'erb'
|
|
21
|
+
require 'fileutils'
|
|
21
22
|
require 'json'
|
|
22
23
|
|
|
23
24
|
module Selenium
|
|
24
25
|
module WebDriver
|
|
25
26
|
module Support
|
|
26
27
|
class CDPClientGenerator
|
|
27
|
-
|
|
28
|
-
BROWSER_PROTOCOL_PATH = File.expand_path('cdp/browser_protocol.json', __dir__)
|
|
29
|
-
JS_PROTOCOL_PATH = File.expand_path('cdp/js_protocol.json', __dir__)
|
|
28
|
+
# Input JSON files are generated from PDL tasks.
|
|
30
29
|
TEMPLATE_PATH = File.expand_path('cdp/domain.rb.erb', __dir__)
|
|
31
30
|
|
|
32
31
|
RESERVED_KEYWORDS = %w[end].freeze
|
|
33
32
|
|
|
34
|
-
def
|
|
35
|
-
@browser_protocol = JSON.parse(File.read(BROWSER_PROTOCOL_PATH), symbolize_names: true)
|
|
36
|
-
@js_protocol = JSON.parse(File.read(JS_PROTOCOL_PATH), symbolize_names: true)
|
|
33
|
+
def call(output_dir:, version:, browser_protocol_path: nil, js_protocol_path: nil, loader_path: nil, **)
|
|
37
34
|
@template = ERB.new(File.read(TEMPLATE_PATH))
|
|
38
|
-
|
|
35
|
+
@output_dir = output_dir
|
|
36
|
+
@loader_path = loader_path || "#{@output_dir}.rb"
|
|
37
|
+
@version = version
|
|
38
|
+
|
|
39
|
+
browser_protocol_path ||= File.expand_path('cdp/browser_protocol.json', __dir__)
|
|
40
|
+
js_protocol_path ||= File.expand_path('cdp/js_protocol.json', __dir__)
|
|
41
|
+
|
|
42
|
+
browser_protocol = JSON.parse(File.read(browser_protocol_path), symbolize_names: true)
|
|
43
|
+
js_protocol = JSON.parse(File.read(js_protocol_path), symbolize_names: true)
|
|
39
44
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
FileUtils.mkdir_p(@output_dir)
|
|
46
|
+
|
|
47
|
+
browser_protocol[:domains].each(&method(:process_domain))
|
|
48
|
+
js_protocol[:domains].each(&method(:process_domain))
|
|
49
|
+
require_file
|
|
43
50
|
end
|
|
44
51
|
|
|
45
52
|
def process_domain(domain)
|
|
46
|
-
result = @template.result_with_hash(domain: domain, h: self)
|
|
47
|
-
filename = File.join(
|
|
53
|
+
result = @template.result_with_hash(domain: domain, version: @version.upcase, h: self)
|
|
54
|
+
filename = File.join(@output_dir, "#{snake_case(domain[:domain])}.rb")
|
|
48
55
|
File.write(filename, remove_empty_lines(result))
|
|
49
56
|
end
|
|
50
57
|
|
|
51
58
|
def snake_case(string)
|
|
52
|
-
name = string.gsub(
|
|
59
|
+
name = string.gsub('JavaScript', 'Javascript')
|
|
60
|
+
.gsub(/([A-Z]+)([A-Z][a-z]{2,})/, '\1_\2')
|
|
61
|
+
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
|
62
|
+
.downcase
|
|
53
63
|
# Certain CDP parameters conflict with Ruby keywords
|
|
54
64
|
# so we prefix the name with underscore.
|
|
55
65
|
name = "_#{name}" if RESERVED_KEYWORDS.include?(name)
|
|
@@ -71,7 +81,28 @@ module Selenium
|
|
|
71
81
|
def remove_empty_lines(string)
|
|
72
82
|
string.split("\n").reject { |l| l =~ /^\s+$/ }.join("\n")
|
|
73
83
|
end
|
|
84
|
+
|
|
85
|
+
def require_file
|
|
86
|
+
# rubocop:disable Lint/InterpolationCheck
|
|
87
|
+
dynamic_location = '#{File.dirname(File.absolute_path(__FILE__))}'
|
|
88
|
+
# rubocop:enable Lint/InterpolationCheck
|
|
89
|
+
|
|
90
|
+
require_all = "Dir.glob(\"#{dynamic_location}/#{@version}/*\", &method(:require))"
|
|
91
|
+
File.open(@loader_path, 'w') { |file| file.write(require_all) }
|
|
92
|
+
end
|
|
74
93
|
end
|
|
75
94
|
end
|
|
76
95
|
end
|
|
77
96
|
end
|
|
97
|
+
|
|
98
|
+
if $PROGRAM_NAME == __FILE__
|
|
99
|
+
browser_protocol_path, js_protocol_path, output_dir, loader_path, version = *ARGV
|
|
100
|
+
|
|
101
|
+
Selenium::WebDriver::Support::CDPClientGenerator.new.call(
|
|
102
|
+
browser_protocol_path: browser_protocol_path,
|
|
103
|
+
js_protocol_path: js_protocol_path,
|
|
104
|
+
output_dir: output_dir,
|
|
105
|
+
loader_path: loader_path,
|
|
106
|
+
version: version
|
|
107
|
+
)
|
|
108
|
+
end
|
|
@@ -120,7 +120,7 @@ module Selenium
|
|
|
120
120
|
returned
|
|
121
121
|
end
|
|
122
122
|
|
|
123
|
-
def method_missing(meth, *args, &blk) # rubocop:disable Style/
|
|
123
|
+
def method_missing(meth, *args, &blk) # rubocop:disable Style/MissingRespondToMissing
|
|
124
124
|
@delegate.__send__(meth, *args, &blk)
|
|
125
125
|
end
|
|
126
126
|
end # EventFiringBridge
|
|
@@ -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].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['SKIP_PENDING']
|
|
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
|