selenium-webdriver 4.1.0 → 4.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +261 -1
- data/Gemfile +2 -0
- data/LICENSE +1 -1
- data/NOTICE +1 -1
- data/README.md +2 -2
- 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 +36 -39
- data/lib/selenium/webdriver/atoms/findElements.js +3 -4
- data/lib/selenium/webdriver/atoms/getAttribute.js +0 -0
- data/lib/selenium/webdriver/atoms/isDisplayed.js +0 -0
- data/lib/selenium/webdriver/atoms/mutationListener.js +0 -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/bidi.rb +56 -0
- data/lib/selenium/webdriver/chrome/driver.rb +9 -29
- data/lib/selenium/webdriver/chrome/features.rb +6 -68
- data/lib/selenium/webdriver/chrome/options.rb +3 -223
- data/lib/selenium/webdriver/chrome/profile.rb +3 -83
- data/lib/selenium/webdriver/chrome/service.rb +0 -22
- data/lib/selenium/webdriver/chrome.rb +0 -14
- data/lib/selenium/webdriver/chromium/driver.rb +61 -0
- data/lib/selenium/webdriver/chromium/features.rb +103 -0
- data/lib/selenium/webdriver/chromium/options.rb +243 -0
- data/lib/selenium/webdriver/chromium/profile.rb +113 -0
- data/lib/selenium/webdriver/chromium.rb +31 -0
- data/lib/selenium/webdriver/common/action_builder.rb +64 -22
- data/lib/selenium/webdriver/common/child_process.rb +124 -0
- data/lib/selenium/webdriver/common/driver.rb +36 -74
- data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +0 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/{has_remote_status.rb → has_bidi.rb} +10 -5
- data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +10 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +1 -4
- data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +1 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +1 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +2 -69
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +1 -3
- data/lib/selenium/webdriver/common/driver_finder.rb +45 -0
- data/lib/selenium/webdriver/common/element.rb +8 -8
- data/lib/selenium/webdriver/common/error.rb +28 -5
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +2 -2
- data/lib/selenium/webdriver/common/interactions/input_device.rb +10 -4
- data/lib/selenium/webdriver/common/interactions/interaction.rb +12 -25
- data/lib/selenium/webdriver/common/interactions/interactions.rb +24 -4
- data/lib/selenium/webdriver/common/interactions/key_actions.rb +5 -1
- data/lib/selenium/webdriver/common/interactions/key_input.rb +11 -27
- data/lib/selenium/webdriver/common/interactions/none_input.rb +10 -8
- data/lib/selenium/webdriver/common/interactions/pause.rb +49 -0
- data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +59 -70
- 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/interactions/wheel_input.rb +42 -0
- data/lib/selenium/webdriver/common/keys.rb +1 -0
- data/lib/selenium/webdriver/common/local_driver.rb +55 -0
- data/lib/selenium/webdriver/common/logger.rb +90 -25
- data/lib/selenium/webdriver/common/manager.rb +0 -27
- data/lib/selenium/webdriver/common/options.rb +13 -17
- data/lib/selenium/webdriver/common/platform.rb +5 -51
- data/lib/selenium/webdriver/common/port_prober.rb +1 -1
- data/lib/selenium/webdriver/common/profile_helper.rb +1 -1
- data/lib/selenium/webdriver/common/proxy.rb +2 -2
- data/lib/selenium/webdriver/common/search_context.rb +0 -6
- data/lib/selenium/webdriver/common/selenium_manager.rb +131 -0
- data/lib/selenium/webdriver/common/service.rb +17 -30
- data/lib/selenium/webdriver/common/service_manager.rb +8 -15
- data/lib/selenium/webdriver/common/shadow_root.rb +2 -3
- data/lib/selenium/webdriver/common/socket_lock.rb +3 -3
- data/lib/selenium/webdriver/common/socket_poller.rb +2 -2
- data/lib/selenium/webdriver/common/takes_screenshot.rb +2 -3
- data/lib/selenium/webdriver/common/target_locator.rb +2 -3
- data/lib/selenium/webdriver/common/timeouts.rb +2 -2
- data/lib/selenium/webdriver/common/virtual_authenticator/credential.rb +85 -0
- data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator.rb +72 -0
- data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator_options.rb +62 -0
- data/lib/selenium/webdriver/common/websocket_connection.rb +164 -0
- data/lib/selenium/webdriver/common/window.rb +6 -6
- data/lib/selenium/webdriver/common/zipper.rb +1 -1
- data/lib/selenium/webdriver/common.rb +21 -3
- data/lib/selenium/webdriver/devtools/console_event.rb +0 -2
- data/lib/selenium/webdriver/devtools/exception_event.rb +0 -2
- data/lib/selenium/webdriver/devtools/mutation_event.rb +0 -2
- data/lib/selenium/webdriver/devtools/network_interceptor.rb +173 -0
- data/lib/selenium/webdriver/devtools/pinned_script.rb +0 -2
- data/lib/selenium/webdriver/devtools/request.rb +1 -3
- data/lib/selenium/webdriver/devtools/response.rb +1 -3
- data/lib/selenium/webdriver/devtools.rb +17 -114
- data/lib/selenium/webdriver/edge/driver.rb +9 -3
- data/lib/selenium/webdriver/edge/features.rb +4 -4
- data/lib/selenium/webdriver/edge/options.rb +17 -5
- data/lib/selenium/webdriver/edge/profile.rb +2 -2
- data/lib/selenium/webdriver/edge/service.rb +1 -7
- data/lib/selenium/webdriver/firefox/driver.rb +9 -2
- data/lib/selenium/webdriver/firefox/features.rb +6 -6
- data/lib/selenium/webdriver/firefox/options.rb +6 -15
- data/lib/selenium/webdriver/firefox/profile.rb +8 -12
- data/lib/selenium/webdriver/firefox/service.rb +0 -18
- data/lib/selenium/webdriver/firefox/util.rb +46 -0
- data/lib/selenium/webdriver/firefox.rb +1 -14
- data/lib/selenium/webdriver/ie/driver.rb +7 -1
- data/lib/selenium/webdriver/ie/options.rb +2 -1
- data/lib/selenium/webdriver/ie/service.rb +0 -22
- data/lib/selenium/webdriver/ie.rb +0 -14
- data/lib/selenium/webdriver/remote/{commands.rb → bridge/commands.rb} +15 -8
- data/lib/selenium/webdriver/remote/bridge.rb +65 -35
- data/lib/selenium/webdriver/remote/capabilities.rb +3 -53
- data/lib/selenium/webdriver/remote/driver.rb +19 -14
- data/lib/selenium/webdriver/remote/http/common.rb +3 -3
- data/lib/selenium/webdriver/remote/http/curb.rb +1 -3
- data/lib/selenium/webdriver/remote/http/default.rb +8 -14
- data/lib/selenium/webdriver/remote/response.rb +2 -3
- data/lib/selenium/webdriver/remote/server_error.rb +1 -1
- data/lib/selenium/webdriver/remote.rb +0 -1
- data/lib/selenium/webdriver/safari/driver.rb +7 -1
- data/lib/selenium/webdriver/safari/features.rb +0 -2
- data/lib/selenium/webdriver/safari/options.rb +5 -1
- data/lib/selenium/webdriver/safari/service.rb +10 -4
- data/lib/selenium/webdriver/safari.rb +1 -15
- data/lib/selenium/webdriver/support/color.rb +22 -22
- data/lib/selenium/webdriver/support/guards/guard.rb +0 -2
- data/lib/selenium/webdriver/support/guards/guard_condition.rb +1 -3
- data/lib/selenium/webdriver/support/guards.rb +1 -1
- data/lib/selenium/webdriver/support/relative_locator.rb +0 -1
- data/lib/selenium/webdriver/support/select.rb +3 -1
- data/lib/selenium/webdriver/version.rb +1 -1
- data/lib/selenium/webdriver.rb +5 -4
- data/selenium-webdriver.gemspec +14 -12
- metadata +73 -63
- data/lib/selenium/webdriver/remote/http/persistent.rb +0 -65
- data/lib/selenium/webdriver/support/cdp/domain.rb.erb +0 -63
- data/lib/selenium/webdriver/support/cdp_client_generator.rb +0 -108
@@ -20,14 +20,12 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Remote
|
23
|
-
|
24
23
|
#
|
25
24
|
# Specification of the desired and/or actual capabilities of the browser that the
|
26
25
|
# server is being asked to create.
|
27
26
|
#
|
28
27
|
|
29
28
|
class Capabilities
|
30
|
-
|
31
29
|
KNOWN = [
|
32
30
|
:browser_name,
|
33
31
|
:browser_version,
|
@@ -55,60 +53,11 @@ module Selenium
|
|
55
53
|
end
|
56
54
|
end
|
57
55
|
|
58
|
-
#
|
59
|
-
# Backward compatibility
|
60
|
-
#
|
61
|
-
|
62
|
-
alias_method :version, :browser_version
|
63
|
-
alias_method :version=, :browser_version=
|
64
|
-
alias_method :platform, :platform_name
|
65
|
-
alias_method :platform=, :platform_name=
|
66
|
-
|
67
56
|
#
|
68
57
|
# Convenience methods for the common choices.
|
69
58
|
#
|
70
59
|
|
71
60
|
class << self
|
72
|
-
def chrome(opts = {})
|
73
|
-
new({
|
74
|
-
browser_name: 'chrome'
|
75
|
-
}.merge(opts))
|
76
|
-
end
|
77
|
-
|
78
|
-
def edge(opts = {})
|
79
|
-
new({
|
80
|
-
browser_name: 'MicrosoftEdge'
|
81
|
-
}.merge(opts))
|
82
|
-
end
|
83
|
-
alias_method :microsoftedge, :edge
|
84
|
-
|
85
|
-
def firefox(opts = {})
|
86
|
-
new({
|
87
|
-
browser_name: 'firefox'
|
88
|
-
}.merge(opts))
|
89
|
-
end
|
90
|
-
alias_method :ff, :firefox
|
91
|
-
|
92
|
-
def safari(opts = {})
|
93
|
-
new({
|
94
|
-
browser_name: Selenium::WebDriver::Safari.technology_preview? ? "Safari Technology Preview" : 'safari'
|
95
|
-
}.merge(opts))
|
96
|
-
end
|
97
|
-
|
98
|
-
def htmlunit(opts = {})
|
99
|
-
new({
|
100
|
-
browser_name: 'htmlunit'
|
101
|
-
}.merge(opts))
|
102
|
-
end
|
103
|
-
|
104
|
-
def internet_explorer(opts = {})
|
105
|
-
new({
|
106
|
-
browser_name: 'internet explorer',
|
107
|
-
platform_name: :windows
|
108
|
-
}.merge(opts))
|
109
|
-
end
|
110
|
-
alias_method :ie, :internet_explorer
|
111
|
-
|
112
61
|
def always_match(capabilities)
|
113
62
|
new(always_match: capabilities)
|
114
63
|
end
|
@@ -134,7 +83,8 @@ module Selenium
|
|
134
83
|
|
135
84
|
# Remote Server Specific
|
136
85
|
if data.key?('webdriver.remote.sessionid')
|
137
|
-
caps[:remote_session_id] =
|
86
|
+
caps[:remote_session_id] =
|
87
|
+
data.delete('webdriver.remote.sessionid')
|
138
88
|
end
|
139
89
|
|
140
90
|
KNOWN.each do |cap|
|
@@ -269,7 +219,7 @@ module Selenium
|
|
269
219
|
as_json == other.as_json
|
270
220
|
end
|
271
221
|
|
272
|
-
|
222
|
+
alias eql? ==
|
273
223
|
|
274
224
|
protected
|
275
225
|
|
@@ -20,7 +20,6 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Remote
|
23
|
-
|
24
23
|
#
|
25
24
|
# Driver implementation for remote server.
|
26
25
|
# @api private
|
@@ -29,19 +28,13 @@ module Selenium
|
|
29
28
|
class Driver < WebDriver::Driver
|
30
29
|
include DriverExtensions::UploadsFiles
|
31
30
|
include DriverExtensions::HasSessionId
|
32
|
-
include DriverExtensions::HasRemoteStatus
|
33
31
|
|
34
|
-
def initialize(
|
35
|
-
|
36
|
-
if desired_capabilities.is_a?(Symbol)
|
37
|
-
unless Remote::Capabilities.respond_to?(desired_capabilities)
|
38
|
-
raise Error::WebDriverError, "invalid desired capability: #{desired_capabilities.inspect}"
|
39
|
-
end
|
32
|
+
def initialize(capabilities: nil, options: nil, service: nil, url: nil, **opts)
|
33
|
+
raise ArgumentError, "Can not set :service object on #{self.class}" if service
|
40
34
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
super
|
35
|
+
url ||= "http://#{Platform.localhost}:4444/wd/hub"
|
36
|
+
caps = process_options(options, capabilities)
|
37
|
+
super(caps: caps, url: url, **opts)
|
45
38
|
@bridge.file_detector = ->((filename, *)) { File.exist?(filename) && filename.to_s }
|
46
39
|
end
|
47
40
|
|
@@ -52,8 +45,20 @@ module Selenium
|
|
52
45
|
end
|
53
46
|
|
54
47
|
def devtools_version
|
55
|
-
capabilities['se:cdpVersion']&.split('.')&.first
|
56
|
-
|
48
|
+
cdp_version = capabilities['se:cdpVersion']&.split('.')&.first
|
49
|
+
raise Error::WebDriverError, 'DevTools is not supported by the Remote Server' unless cdp_version
|
50
|
+
|
51
|
+
Integer(cdp_version)
|
52
|
+
end
|
53
|
+
|
54
|
+
def process_options(options, capabilities)
|
55
|
+
if options && capabilities
|
56
|
+
msg = "Don't use both :options and :capabilities when initializing #{self.class}, prefer :options"
|
57
|
+
raise ArgumentError, msg
|
58
|
+
elsif options.nil? && capabilities.nil?
|
59
|
+
raise ArgumentError, "#{self.class} needs :options to be set"
|
60
|
+
end
|
61
|
+
options ? options.as_json : generate_capabilities(capabilities)
|
57
62
|
end
|
58
63
|
end # Driver
|
59
64
|
end # Remote
|
@@ -49,8 +49,8 @@ module Selenium
|
|
49
49
|
payload = JSON.generate(command_hash)
|
50
50
|
headers['Content-Length'] = payload.bytesize.to_s if %i[post put].include?(verb)
|
51
51
|
|
52
|
-
WebDriver.logger.
|
53
|
-
WebDriver.logger.debug(" > #{headers.inspect}")
|
52
|
+
WebDriver.logger.debug(" >>> #{url} | #{payload}", id: :command)
|
53
|
+
WebDriver.logger.debug(" > #{headers.inspect}", id: :header)
|
54
54
|
elsif verb == :post
|
55
55
|
payload = '{}'
|
56
56
|
headers['Content-Length'] = '2'
|
@@ -75,7 +75,7 @@ module Selenium
|
|
75
75
|
code = code.to_i
|
76
76
|
body = body.to_s.strip
|
77
77
|
content_type = content_type.to_s
|
78
|
-
WebDriver.logger.
|
78
|
+
WebDriver.logger.debug("<- #{body}", id: :command)
|
79
79
|
|
80
80
|
if content_type.include? CONTENT_TYPE
|
81
81
|
raise Error::WebDriverError, "empty body: #{content_type.inspect} (#{code})\n#{body}" if body.empty?
|
@@ -22,7 +22,6 @@ require 'curb'
|
|
22
22
|
module Selenium
|
23
23
|
module WebDriver
|
24
24
|
module Remote
|
25
|
-
|
26
25
|
module Http
|
27
26
|
#
|
28
27
|
# An alternative to the default Net::HTTP client.
|
@@ -38,7 +37,6 @@ module Selenium
|
|
38
37
|
#
|
39
38
|
|
40
39
|
class Curb < Common
|
41
|
-
|
42
40
|
def quit_errors
|
43
41
|
[Curl::Err::RecvError] + super
|
44
42
|
end
|
@@ -85,7 +83,7 @@ module Selenium
|
|
85
83
|
c.max_redirects = MAX_REDIRECTS
|
86
84
|
c.follow_location = true
|
87
85
|
c.timeout = @timeout if @timeout
|
88
|
-
c.verbose = WebDriver.logger.
|
86
|
+
c.verbose = WebDriver.logger.debug?
|
89
87
|
|
90
88
|
c
|
91
89
|
end
|
@@ -16,8 +16,6 @@
|
|
16
16
|
# KIND, either express or implied. See the License for the
|
17
17
|
# specific language governing permissions and limitations
|
18
18
|
# under the License.
|
19
|
-
|
20
|
-
require 'net/https'
|
21
19
|
require 'ipaddr'
|
22
20
|
|
23
21
|
module Selenium
|
@@ -75,9 +73,10 @@ module Selenium
|
|
75
73
|
begin
|
76
74
|
request = new_request_for(verb, url, headers, payload)
|
77
75
|
response = response_for(request)
|
78
|
-
rescue Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EADDRINUSE
|
79
|
-
# a retry is sometimes needed
|
80
|
-
# run out of ephemeral ports
|
76
|
+
rescue Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EADDRINUSE, Errno::EADDRNOTAVAIL
|
77
|
+
# a retry is sometimes needed:
|
78
|
+
# on Windows XP where we may quickly run out of ephemeral ports
|
79
|
+
# when the port becomes temporarily unavailable
|
81
80
|
#
|
82
81
|
# A more robust solution is bumping the MaxUserPort setting
|
83
82
|
# as described here:
|
@@ -85,13 +84,6 @@ module Selenium
|
|
85
84
|
# http://msdn.microsoft.com/en-us/library/aa560610%28v=bts.20%29.aspx
|
86
85
|
raise if retries >= MAX_RETRIES
|
87
86
|
|
88
|
-
retries += 1
|
89
|
-
sleep 2
|
90
|
-
retry
|
91
|
-
rescue Errno::EADDRNOTAVAIL => e
|
92
|
-
# a retry is sometimes needed when the port becomes temporarily unavailable
|
93
|
-
raise if retries >= MAX_RETRIES
|
94
|
-
|
95
87
|
retries += 1
|
96
88
|
sleep 2
|
97
89
|
retry
|
@@ -102,10 +94,12 @@ module Selenium
|
|
102
94
|
end
|
103
95
|
|
104
96
|
if response.is_a? Net::HTTPRedirection
|
97
|
+
WebDriver.logger.debug("Redirect to #{response['Location']}; times: #{redirects}")
|
105
98
|
raise Error::WebDriverError, 'too many redirects' if redirects >= MAX_REDIRECTS
|
106
99
|
|
107
100
|
request(:get, URI.parse(response['Location']), DEFAULT_HEADERS.dup, nil, redirects + 1)
|
108
101
|
else
|
102
|
+
WebDriver.logger.debug(" <<< #{response.instance_variable_get(:@header).inspect}", id: :header)
|
109
103
|
create_response response.code, response.body, response.content_type
|
110
104
|
end
|
111
105
|
end
|
@@ -142,8 +136,8 @@ module Selenium
|
|
142
136
|
|
143
137
|
def proxy
|
144
138
|
@proxy ||= begin
|
145
|
-
proxy = ENV
|
146
|
-
no_proxy = ENV
|
139
|
+
proxy = ENV.fetch('http_proxy', nil) || ENV.fetch('HTTP_PROXY', nil)
|
140
|
+
no_proxy = ENV.fetch('no_proxy', nil) || ENV.fetch('NO_PROXY', nil)
|
147
141
|
|
148
142
|
if proxy
|
149
143
|
proxy = "http://#{proxy}" unless proxy.start_with?('http://')
|
@@ -20,7 +20,6 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Remote
|
23
|
-
|
24
23
|
#
|
25
24
|
# @api private
|
26
25
|
#
|
@@ -74,7 +73,7 @@ module Selenium
|
|
74
73
|
end
|
75
74
|
|
76
75
|
def backtrace_from_remote(server_trace)
|
77
|
-
server_trace.
|
76
|
+
server_trace.filter_map do |frame|
|
78
77
|
next unless frame.is_a?(Hash)
|
79
78
|
|
80
79
|
file = frame['fileName']
|
@@ -87,7 +86,7 @@ module Selenium
|
|
87
86
|
meth = 'unknown' if meth.nil? || meth.empty?
|
88
87
|
|
89
88
|
"[remote server] #{file}:#{line}:in `#{meth}'"
|
90
|
-
|
89
|
+
end
|
91
90
|
end
|
92
91
|
|
93
92
|
def process_error
|
@@ -27,7 +27,6 @@ module Selenium
|
|
27
27
|
autoload :Driver, 'selenium/webdriver/remote/driver'
|
28
28
|
autoload :Response, 'selenium/webdriver/remote/response'
|
29
29
|
autoload :Capabilities, 'selenium/webdriver/remote/capabilities'
|
30
|
-
autoload :COMMANDS, 'selenium/webdriver/remote/commands'
|
31
30
|
|
32
31
|
module Http
|
33
32
|
autoload :Common, 'selenium/webdriver/remote/http/common'
|
@@ -20,7 +20,6 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Safari
|
23
|
-
|
24
23
|
#
|
25
24
|
# Driver implementation for Safari.
|
26
25
|
# @api private
|
@@ -31,6 +30,13 @@ module Selenium
|
|
31
30
|
DriverExtensions::HasApplePermissions,
|
32
31
|
DriverExtensions::HasWebStorage].freeze
|
33
32
|
|
33
|
+
include LocalDriver
|
34
|
+
|
35
|
+
def initialize(capabilities: nil, options: nil, service: nil, url: nil, **opts)
|
36
|
+
caps, url = initialize_local_driver(capabilities, options, service, url)
|
37
|
+
super(caps: caps, url: url, **opts)
|
38
|
+
end
|
39
|
+
|
34
40
|
def browser
|
35
41
|
:safari
|
36
42
|
end
|
@@ -21,7 +21,6 @@ module Selenium
|
|
21
21
|
module WebDriver
|
22
22
|
module Safari
|
23
23
|
module Features
|
24
|
-
|
25
24
|
# https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/WebDriverEndpointDoc/Commands/Commands.html
|
26
25
|
SAFARI_COMMANDS = {
|
27
26
|
get_permissions: [:get, 'session/:session_id/apple/permissions'],
|
@@ -44,7 +43,6 @@ module Selenium
|
|
44
43
|
def attach_debugger
|
45
44
|
execute :attach_debugger, {}, {}
|
46
45
|
end
|
47
|
-
|
48
46
|
end # Bridge
|
49
47
|
end # Safari
|
50
48
|
end # WebDriver
|
@@ -26,7 +26,7 @@ module Selenium
|
|
26
26
|
# @see https://developer.apple.com/documentation/webkit/about_webdriver_for_safari
|
27
27
|
CAPABILITIES = {automatic_inspection: 'safari:automaticInspection',
|
28
28
|
automatic_profiling: 'safari:automaticProfiling'}.freeze
|
29
|
-
BROWSER = 'safari'
|
29
|
+
BROWSER = Selenium::WebDriver::Safari.technology_preview? ? 'Safari Technology Preview' : 'safari'
|
30
30
|
|
31
31
|
def add_option(name, value = nil)
|
32
32
|
key = name.is_a?(Hash) ? name.keys.first : name
|
@@ -35,6 +35,10 @@ module Selenium
|
|
35
35
|
super
|
36
36
|
end
|
37
37
|
|
38
|
+
def as_json(*)
|
39
|
+
@options[:browser_name] = Safari.technology_preview? ? 'Safari Technology Preview' : 'safari'
|
40
|
+
super
|
41
|
+
end
|
38
42
|
end # Options
|
39
43
|
end # Safari
|
40
44
|
end # WebDriver
|
@@ -23,11 +23,17 @@ module Selenium
|
|
23
23
|
class Service < WebDriver::Service
|
24
24
|
DEFAULT_PORT = 7050
|
25
25
|
EXECUTABLE = 'safaridriver'
|
26
|
-
MISSING_TEXT = <<~ERROR
|
27
|
-
Unable to find Apple's safaridriver which comes with Safari 10.
|
28
|
-
More info at https://webkit.org/blog/6900/webdriver-support-in-safari-10/
|
29
|
-
ERROR
|
30
26
|
SHUTDOWN_SUPPORTED = false
|
27
|
+
|
28
|
+
def initialize(path: nil, port: nil, log: nil, args: nil)
|
29
|
+
raise Error::WebDriverError, 'Safari Service does not support setting log output' if log
|
30
|
+
|
31
|
+
super
|
32
|
+
end
|
33
|
+
|
34
|
+
def log=(*)
|
35
|
+
raise Error::WebDriverError, 'Safari Service does not support setting log output'
|
36
|
+
end
|
31
37
|
end # Service
|
32
38
|
end # Safari
|
33
39
|
end # WebDriver
|
@@ -29,7 +29,7 @@ module Selenium
|
|
29
29
|
attr_accessor :use_technology_preview
|
30
30
|
|
31
31
|
def technology_preview
|
32
|
-
|
32
|
+
'/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver'
|
33
33
|
end
|
34
34
|
|
35
35
|
def technology_preview!
|
@@ -53,20 +53,6 @@ module Selenium
|
|
53
53
|
|
54
54
|
raise Error::WebDriverError, 'Unable to find Safari'
|
55
55
|
end
|
56
|
-
|
57
|
-
def driver_path=(path)
|
58
|
-
WebDriver.logger.deprecate 'Selenium::WebDriver::Safari#driver_path=',
|
59
|
-
'Selenium::WebDriver::Safari::Service#driver_path=',
|
60
|
-
id: :driver_path
|
61
|
-
Selenium::WebDriver::Safari::Service.driver_path = path
|
62
|
-
end
|
63
|
-
|
64
|
-
def driver_path
|
65
|
-
WebDriver.logger.deprecate 'Selenium::WebDriver::Safari#driver_path',
|
66
|
-
'Selenium::WebDriver::Safari::Service#driver_path',
|
67
|
-
id: :driver_path
|
68
|
-
Selenium::WebDriver::Safari::Service.driver_path
|
69
|
-
end
|
70
56
|
end
|
71
57
|
end # Safari
|
72
58
|
end # WebDriver
|
@@ -21,29 +21,29 @@ module Selenium
|
|
21
21
|
module WebDriver
|
22
22
|
module Support
|
23
23
|
class Color
|
24
|
-
RGB_PATTERN =
|
24
|
+
RGB_PATTERN = /^\s*rgb\(\s*(\d{1,3})\s*,
|
25
25
|
\s*(\d{1,3})\s*,
|
26
|
-
\s*(\d{1,3})\s*\)\s
|
27
|
-
RGB_PCT_PATTERN =
|
26
|
+
\s*(\d{1,3})\s*\)\s*$/x
|
27
|
+
RGB_PCT_PATTERN = /^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,
|
28
28
|
\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,
|
29
|
-
\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s
|
30
|
-
RGBA_PATTERN =
|
29
|
+
\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$/x
|
30
|
+
RGBA_PATTERN = /^\s*rgba\(\s*(\d{1,3})\s*,
|
31
31
|
\s*(\d{1,3})\s*,
|
32
32
|
\s*(\d{1,3})\s*,
|
33
|
-
\s*(0|1|0\.\d+)\s*\)\s
|
34
|
-
RGBA_PCT_PATTERN =
|
33
|
+
\s*(0|1|0\.\d+)\s*\)\s*$/x
|
34
|
+
RGBA_PCT_PATTERN = /^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)
|
35
35
|
%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)
|
36
36
|
%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)
|
37
|
-
%\s*,\s*(0|1|0\.\d+)\s*\)\s
|
38
|
-
HEX_PATTERN = /#(\h{2})(\h{2})(\h{2})
|
39
|
-
HEX3_PATTERN = /#(\h)(\h)(\h)
|
40
|
-
HSL_PATTERN =
|
37
|
+
%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/x
|
38
|
+
HEX_PATTERN = /#(\h{2})(\h{2})(\h{2})/
|
39
|
+
HEX3_PATTERN = /#(\h)(\h)(\h)/
|
40
|
+
HSL_PATTERN = /^\s*hsl\(\s*(\d{1,3})\s*,
|
41
41
|
\s*(\d{1,3})%\s*,
|
42
|
-
\s*(\d{1,3})%\s*\)\s
|
43
|
-
HSLA_PATTERN =
|
42
|
+
\s*(\d{1,3})%\s*\)\s*$/x
|
43
|
+
HSLA_PATTERN = /^\s*hsla\(\s*(\d{1,3})\s*,
|
44
44
|
\s*(\d{1,3})%\s*,
|
45
45
|
\s*(\d{1,3})%\s*,
|
46
|
-
\s*(0|1|0\.\d+)\s*\)\s
|
46
|
+
\s*(0|1|0\.\d+)\s*\)\s*$/x
|
47
47
|
|
48
48
|
attr_reader :red, :green, :blue, :alpha
|
49
49
|
|
@@ -83,12 +83,12 @@ module Selenium
|
|
83
83
|
g = r
|
84
84
|
b = r
|
85
85
|
else
|
86
|
-
luminocity2 = l < 0.5 ? l * (
|
87
|
-
luminocity1 =
|
86
|
+
luminocity2 = l < 0.5 ? l * (s + 1) : l + s - (l * s)
|
87
|
+
luminocity1 = (l * 2) - luminocity2
|
88
88
|
|
89
|
-
r = hue_to_rgb(luminocity1, luminocity2, h + 1.0 / 3.0)
|
89
|
+
r = hue_to_rgb(luminocity1, luminocity2, h + (1.0 / 3.0))
|
90
90
|
g = hue_to_rgb(luminocity1, luminocity2, h)
|
91
|
-
b = hue_to_rgb(luminocity1, luminocity2, h - 1.0 / 3.0)
|
91
|
+
b = hue_to_rgb(luminocity1, luminocity2, h - (1.0 / 3.0))
|
92
92
|
end
|
93
93
|
|
94
94
|
new (r * 255).round, (g * 255).round, (b * 255).round, a
|
@@ -99,11 +99,11 @@ module Selenium
|
|
99
99
|
hue -= 1 if hue > 1.0
|
100
100
|
|
101
101
|
if hue < 1.0 / 6.0
|
102
|
-
(lum1 + (lum2 - lum1) * 6.0 * hue)
|
102
|
+
(lum1 + ((lum2 - lum1) * 6.0 * hue))
|
103
103
|
elsif hue < 1.0 / 2.0
|
104
104
|
lum2
|
105
105
|
elsif hue < 2.0 / 3.0
|
106
|
-
lum1 + (lum2 - lum1) * ((2.0 / 3.0) - hue) * 6.0
|
106
|
+
lum1 + ((lum2 - lum1) * ((2.0 / 3.0) - hue) * 6.0)
|
107
107
|
else
|
108
108
|
lum1
|
109
109
|
end
|
@@ -122,10 +122,10 @@ module Selenium
|
|
122
122
|
|
123
123
|
[red, green, blue, alpha] == [other.red, other.green, other.blue, other.alpha]
|
124
124
|
end
|
125
|
-
|
125
|
+
alias eql? ==
|
126
126
|
|
127
127
|
def hash
|
128
|
-
[red, green, blue, alpha
|
128
|
+
[red, green, blue, alpha, self.class].hash
|
129
129
|
end
|
130
130
|
|
131
131
|
def rgb
|
@@ -21,14 +21,12 @@ module Selenium
|
|
21
21
|
module WebDriver
|
22
22
|
module Support
|
23
23
|
class Guards
|
24
|
-
|
25
24
|
#
|
26
25
|
# Guard derived from RSpec example metadata.
|
27
26
|
# @api private
|
28
27
|
#
|
29
28
|
|
30
29
|
class Guard
|
31
|
-
|
32
30
|
attr_reader :guarded, :type, :messages, :reason
|
33
31
|
|
34
32
|
def initialize(guarded, type, guards = nil)
|
@@ -21,7 +21,6 @@ module Selenium
|
|
21
21
|
module WebDriver
|
22
22
|
module Support
|
23
23
|
class Guards
|
24
|
-
|
25
24
|
#
|
26
25
|
# Guard derived from RSpec example metadata.
|
27
26
|
# @api private
|
@@ -32,7 +31,7 @@ module Selenium
|
|
32
31
|
|
33
32
|
def initialize(name, condition = nil, &blk)
|
34
33
|
@name = name
|
35
|
-
@execution = if
|
34
|
+
@execution = if blk
|
36
35
|
proc(&blk)
|
37
36
|
else
|
38
37
|
proc { |guarded| guarded.include?(condition) }
|
@@ -44,7 +43,6 @@ module Selenium
|
|
44
43
|
|
45
44
|
list.empty? || @execution.call(list)
|
46
45
|
end
|
47
|
-
|
48
46
|
end # GuardCondition
|
49
47
|
end # Guards
|
50
48
|
end # Support
|
@@ -48,7 +48,7 @@ module Selenium
|
|
48
48
|
def disposition
|
49
49
|
if !skipping_guard.nil?
|
50
50
|
[:skip, skipping_guard.message]
|
51
|
-
elsif !pending_guard.nil? && ENV
|
51
|
+
elsif !pending_guard.nil? && ENV.fetch('SKIP_PENDING', nil)
|
52
52
|
[:skip, pending_guard.message]
|
53
53
|
elsif !pending_guard.nil?
|
54
54
|
[:pending, pending_guard.message]
|
@@ -86,7 +86,7 @@ module Selenium
|
|
86
86
|
#
|
87
87
|
# <option value="foo">Bar</option>
|
88
88
|
#
|
89
|
-
# When
|
89
|
+
# When selecting by :value, selects all options that have a value matching the argument. That is, when given "foo" this
|
90
90
|
# would select an option like:
|
91
91
|
#
|
92
92
|
# <option value="foo">Bar</option>
|
@@ -215,6 +215,8 @@ module Selenium
|
|
215
215
|
end
|
216
216
|
|
217
217
|
def select_option(option)
|
218
|
+
raise Error::UnsupportedOperationError, 'You may not select a disabled option' unless option.enabled?
|
219
|
+
|
218
220
|
option.click unless option.selected?
|
219
221
|
end
|
220
222
|
|
data/lib/selenium/webdriver.rb
CHANGED
@@ -17,7 +17,6 @@
|
|
17
17
|
# specific language governing permissions and limitations
|
18
18
|
# under the License.
|
19
19
|
|
20
|
-
require 'childprocess'
|
21
20
|
require 'tmpdir'
|
22
21
|
require 'fileutils'
|
23
22
|
require 'date'
|
@@ -34,8 +33,9 @@ module Selenium
|
|
34
33
|
Point = Struct.new(:x, :y)
|
35
34
|
Dimension = Struct.new(:width, :height)
|
36
35
|
Rectangle = Struct.new(:x, :y, :width, :height)
|
37
|
-
Location = Struct.new(:latitude, :longitude, :altitude)
|
38
36
|
|
37
|
+
autoload :BiDi, 'selenium/webdriver/bidi'
|
38
|
+
autoload :Chromium, 'selenium/webdriver/chromium'
|
39
39
|
autoload :Chrome, 'selenium/webdriver/chrome'
|
40
40
|
autoload :DevTools, 'selenium/webdriver/devtools'
|
41
41
|
autoload :Edge, 'selenium/webdriver/edge'
|
@@ -94,8 +94,9 @@ module Selenium
|
|
94
94
|
# @return [Logger]
|
95
95
|
#
|
96
96
|
|
97
|
-
def self.logger
|
98
|
-
|
97
|
+
def self.logger(**opts)
|
98
|
+
level = $DEBUG || ENV.key?('DEBUG') ? :debug : :info
|
99
|
+
@logger ||= WebDriver::Logger.new('Selenium', default_level: level, **opts)
|
99
100
|
end
|
100
101
|
end # WebDriver
|
101
102
|
end # Selenium
|