selenium-webdriver 4.7.1 → 4.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES +29 -0
- data/LICENSE +1 -1
- data/NOTICE +1 -1
- data/lib/selenium/server.rb +1 -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/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 +140 -0
- data/lib/selenium/webdriver/bidi/navigate_result.rb +33 -0
- data/lib/selenium/webdriver/bidi/session.rb +13 -0
- data/lib/selenium/webdriver/bidi.rb +2 -1
- data/lib/selenium/webdriver/chrome/driver.rb +19 -29
- data/lib/selenium/webdriver/chrome/features.rb +5 -72
- data/lib/selenium/webdriver/chrome/options.rb +3 -237
- data/lib/selenium/webdriver/chrome/profile.rb +3 -83
- data/lib/selenium/webdriver/chrome/service.rb +3 -18
- 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 +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 +11 -48
- data/lib/selenium/webdriver/common/child_process.rb +0 -2
- data/lib/selenium/webdriver/common/driver.rb +34 -25
- 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_bidi.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +0 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +0 -2
- 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 +0 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +0 -2
- data/lib/selenium/webdriver/common/element.rb +6 -6
- data/lib/selenium/webdriver/common/error.rb +0 -2
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +2 -2
- data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +3 -3
- data/lib/selenium/webdriver/common/interactions/pointer_move.rb +2 -2
- data/lib/selenium/webdriver/common/interactions/scroll.rb +7 -5
- data/lib/selenium/webdriver/common/logger.rb +10 -2
- data/lib/selenium/webdriver/common/options.rb +30 -8
- data/lib/selenium/webdriver/common/profile_helper.rb +1 -1
- data/lib/selenium/webdriver/common/proxy.rb +1 -1
- data/lib/selenium/webdriver/common/selenium_manager.rb +10 -12
- data/lib/selenium/webdriver/common/service.rb +9 -5
- data/lib/selenium/webdriver/common/service_manager.rb +1 -1
- data/lib/selenium/webdriver/common/shadow_root.rb +1 -2
- data/lib/selenium/webdriver/common/socket_lock.rb +1 -0
- 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 +8 -6
- data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator.rb +0 -1
- data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator_options.rb +16 -16
- data/lib/selenium/webdriver/common/websocket_connection.rb +1 -2
- 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 +3 -6
- data/lib/selenium/webdriver/devtools/pinned_script.rb +0 -2
- data/lib/selenium/webdriver/devtools/request.rb +0 -2
- data/lib/selenium/webdriver/devtools/response.rb +0 -2
- data/lib/selenium/webdriver/devtools.rb +0 -1
- data/lib/selenium/webdriver/edge/driver.rb +20 -3
- data/lib/selenium/webdriver/edge/features.rb +3 -4
- data/lib/selenium/webdriver/edge/options.rb +3 -5
- data/lib/selenium/webdriver/edge/profile.rb +2 -2
- data/lib/selenium/webdriver/edge/service.rb +2 -2
- data/lib/selenium/webdriver/firefox/driver.rb +19 -2
- data/lib/selenium/webdriver/firefox/features.rb +0 -1
- data/lib/selenium/webdriver/firefox/options.rb +4 -1
- data/lib/selenium/webdriver/firefox/profile.rb +6 -6
- data/lib/selenium/webdriver/firefox/service.rb +0 -1
- data/lib/selenium/webdriver/ie/driver.rb +20 -1
- data/lib/selenium/webdriver/ie/service.rb +1 -2
- data/lib/selenium/webdriver/remote/bridge.rb +8 -15
- data/lib/selenium/webdriver/remote/capabilities.rb +34 -12
- data/lib/selenium/webdriver/remote/commands.rb +0 -2
- data/lib/selenium/webdriver/remote/driver.rb +13 -13
- data/lib/selenium/webdriver/remote/http/curb.rb +0 -2
- data/lib/selenium/webdriver/remote/http/default.rb +1 -0
- data/lib/selenium/webdriver/remote/response.rb +0 -1
- data/lib/selenium/webdriver/safari/driver.rb +20 -1
- data/lib/selenium/webdriver/safari/features.rb +0 -2
- data/lib/selenium/webdriver/safari/options.rb +5 -1
- data/lib/selenium/webdriver/safari.rb +1 -1
- data/lib/selenium/webdriver/support/color.rb +15 -15
- data/lib/selenium/webdriver/support/guards/guard.rb +0 -2
- data/lib/selenium/webdriver/support/guards/guard_condition.rb +0 -2
- data/lib/selenium/webdriver/support/relative_locator.rb +0 -1
- data/lib/selenium/webdriver/version.rb +1 -1
- data/lib/selenium/webdriver.rb +3 -3
- data/selenium-webdriver.gemspec +3 -5
- metadata +25 -41
- data/lib/selenium/webdriver/support/cdp_client_generator.rb +0 -108
- data/lib/selenium/webdriver/support/nightly_version_generator.rb +0 -60
@@ -26,11 +26,11 @@ module Selenium
|
|
26
26
|
VALID_PREFERENCE_TYPES = [TrueClass, FalseClass, Integer, Float, String].freeze
|
27
27
|
|
28
28
|
DEFAULT_PREFERENCES = {
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
'browser.newtabpage.enabled' => false,
|
30
|
+
'browser.startup.homepage' => 'about:blank',
|
31
|
+
'browser.usedOnWindows10.introURL' => 'about:blank',
|
32
|
+
'network.captive-portal-service.enabled' => false,
|
33
|
+
'security.csp.enable' => false
|
34
34
|
}.freeze
|
35
35
|
|
36
36
|
attr_reader :name, :log_file
|
@@ -143,7 +143,7 @@ module Selenium
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
-
|
146
|
+
alias as_json encoded
|
147
147
|
|
148
148
|
private
|
149
149
|
|
@@ -20,7 +20,6 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module IE
|
23
|
-
|
24
23
|
#
|
25
24
|
# Driver implementation for Internet Explorer supporting
|
26
25
|
# both OSS and W3C dialects of JSON wire protocol.
|
@@ -30,9 +29,29 @@ module Selenium
|
|
30
29
|
class Driver < WebDriver::Driver
|
31
30
|
EXTENSIONS = [DriverExtensions::HasWebStorage].freeze
|
32
31
|
|
32
|
+
def initialize(capabilities: nil, options: nil, service: nil, url: nil, **opts)
|
33
|
+
raise ArgumentError, "Can't initialize #{self.class} with :url" if url
|
34
|
+
|
35
|
+
caps = process_options(options, capabilities)
|
36
|
+
url = service_url(service || Service.ie)
|
37
|
+
super(caps: caps, url: url, **opts)
|
38
|
+
end
|
39
|
+
|
33
40
|
def browser
|
34
41
|
:internet_explorer
|
35
42
|
end
|
43
|
+
|
44
|
+
private
|
45
|
+
|
46
|
+
def process_options(options, capabilities)
|
47
|
+
if options && !options.is_a?(Options)
|
48
|
+
raise ArgumentError, ":options must be an instance of #{Options}"
|
49
|
+
elsif options.nil? && capabilities.nil?
|
50
|
+
options = Options.new
|
51
|
+
end
|
52
|
+
|
53
|
+
super(options, capabilities)
|
54
|
+
end
|
36
55
|
end # Driver
|
37
56
|
end # IE
|
38
57
|
end # WebDriver
|
@@ -32,7 +32,6 @@ module Selenium
|
|
32
32
|
|
33
33
|
private
|
34
34
|
|
35
|
-
# NOTE: This processing is deprecated
|
36
35
|
def extract_service_args(driver_opts)
|
37
36
|
driver_args = super
|
38
37
|
driver_opts = driver_opts.dup
|
@@ -43,7 +42,7 @@ module Selenium
|
|
43
42
|
end
|
44
43
|
driver_args << "--host=#{driver_opts[:host]}" if driver_opts.key?(:host)
|
45
44
|
driver_args << "--extract_path=#{driver_opts[:extract_path]}" if driver_opts.key?(:extract_path)
|
46
|
-
driver_args <<
|
45
|
+
driver_args << '--silent' if driver_opts[:silent] == true
|
47
46
|
driver_args
|
48
47
|
end
|
49
48
|
end # Server
|
@@ -186,6 +186,7 @@ module Selenium
|
|
186
186
|
execute :delete_session
|
187
187
|
http.close
|
188
188
|
rescue *QUIT_ERRORS
|
189
|
+
nil
|
189
190
|
end
|
190
191
|
|
191
192
|
def close
|
@@ -367,18 +368,10 @@ module Selenium
|
|
367
368
|
# actions
|
368
369
|
#
|
369
370
|
|
370
|
-
def action(
|
371
|
-
ActionBuilder.new self,
|
372
|
-
end
|
373
|
-
alias_method :actions, :action
|
374
|
-
|
375
|
-
def mouse
|
376
|
-
raise Error::UnsupportedOperationError, '#mouse is no longer supported, use #action instead'
|
377
|
-
end
|
378
|
-
|
379
|
-
def keyboard
|
380
|
-
raise Error::UnsupportedOperationError, '#keyboard is no longer supported, use #action instead'
|
371
|
+
def action(async: false, devices: [], duration: 250)
|
372
|
+
ActionBuilder.new self, async: async, devices: devices, duration: duration
|
381
373
|
end
|
374
|
+
alias actions action
|
382
375
|
|
383
376
|
def send_actions(data)
|
384
377
|
execute :actions, {}, {actions: data}
|
@@ -400,7 +393,7 @@ module Selenium
|
|
400
393
|
# TODO: rework file detectors before Selenium 4.0
|
401
394
|
if @file_detector
|
402
395
|
local_files = keys.first&.split("\n")&.map { |key| @file_detector.call(Array(key)) }&.compact
|
403
|
-
if local_files
|
396
|
+
if local_files&.any?
|
404
397
|
keys = local_files.map { |local_file| upload(local_file) }
|
405
398
|
keys = Array(keys.join("\n"))
|
406
399
|
end
|
@@ -425,7 +418,7 @@ module Selenium
|
|
425
418
|
end
|
426
419
|
|
427
420
|
def submit_element(element)
|
428
|
-
script = "var form = arguments[0];\n" \
|
421
|
+
script = "/* submitForm */ var form = arguments[0];\n" \
|
429
422
|
"while (form.nodeName != \"FORM\" && form.parentNode) {\n " \
|
430
423
|
"form = form.parentNode;\n" \
|
431
424
|
"}\n" \
|
@@ -437,7 +430,7 @@ module Selenium
|
|
437
430
|
|
438
431
|
execute_script(script, Element::ELEMENT_KEY => element)
|
439
432
|
rescue Error::JavascriptError
|
440
|
-
raise Error::UnsupportedOperationError,
|
433
|
+
raise Error::UnsupportedOperationError, 'To submit an element, it must be nested inside a form element'
|
441
434
|
end
|
442
435
|
|
443
436
|
#
|
@@ -525,7 +518,7 @@ module Selenium
|
|
525
518
|
Element.new self, element_id_from(execute(:get_active_element))
|
526
519
|
end
|
527
520
|
|
528
|
-
|
521
|
+
alias switch_to_active_element active_element
|
529
522
|
|
530
523
|
def find_element_by(how, what, parent_ref = [])
|
531
524
|
how, what = convert_locator(how, what)
|
@@ -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,
|
@@ -59,10 +57,25 @@ module Selenium
|
|
59
57
|
# Backward compatibility
|
60
58
|
#
|
61
59
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
def version
|
61
|
+
WebDriver.logger.deprecate('`Capabilities#version`', '`Capabilities#browser_version`', id: :jwp_caps)
|
62
|
+
browser_version
|
63
|
+
end
|
64
|
+
|
65
|
+
def version=(value)
|
66
|
+
WebDriver.logger.deprecate('`Capabilities#version=`', '`Capabilities#browser_version=`', id: :jwp_caps)
|
67
|
+
self.browser_version = value
|
68
|
+
end
|
69
|
+
|
70
|
+
def platform
|
71
|
+
WebDriver.logger.deprecate('`Capabilities#platform`', '`Capabilities#platform_name`', id: :jwp_caps)
|
72
|
+
platform_name
|
73
|
+
end
|
74
|
+
|
75
|
+
def platform=(value)
|
76
|
+
WebDriver.logger.deprecate('`Capabilities#platform=`', '`Capabilities#platform_name=`', id: :jwp_caps)
|
77
|
+
self.platform_name = value
|
78
|
+
end
|
66
79
|
|
67
80
|
#
|
68
81
|
# Convenience methods for the common choices.
|
@@ -70,44 +83,52 @@ module Selenium
|
|
70
83
|
|
71
84
|
class << self
|
72
85
|
def chrome(opts = {})
|
86
|
+
WebDriver.logger.deprecate('Remote::Capabilities.chrome', 'Options.chrome', id: :caps_browsers)
|
73
87
|
new({
|
74
88
|
browser_name: 'chrome'
|
75
89
|
}.merge(opts))
|
76
90
|
end
|
77
91
|
|
78
92
|
def edge(opts = {})
|
93
|
+
WebDriver.logger.deprecate('Remote::Capabilities.edge', 'Options.edge', id: :caps_browsers)
|
79
94
|
new({
|
80
95
|
browser_name: 'MicrosoftEdge'
|
81
96
|
}.merge(opts))
|
82
97
|
end
|
83
|
-
|
98
|
+
alias microsoftedge edge
|
84
99
|
|
85
100
|
def firefox(opts = {})
|
101
|
+
WebDriver.logger.deprecate('Remote::Capabilities.firefox', 'Options.firefox', id: :caps_browsers)
|
86
102
|
new({
|
87
103
|
browser_name: 'firefox'
|
88
104
|
}.merge(opts))
|
89
105
|
end
|
90
|
-
|
106
|
+
alias ff firefox
|
91
107
|
|
92
108
|
def safari(opts = {})
|
109
|
+
WebDriver.logger.deprecate('Remote::Capabilities.safari', 'Options.safari', id: :caps_browsers)
|
93
110
|
new({
|
94
|
-
browser_name: Selenium::WebDriver::Safari.technology_preview? ?
|
111
|
+
browser_name: Selenium::WebDriver::Safari.technology_preview? ? 'Safari Technology Preview' : 'safari'
|
95
112
|
}.merge(opts))
|
96
113
|
end
|
97
114
|
|
98
115
|
def htmlunit(opts = {})
|
116
|
+
WebDriver.logger.deprecate('Remote::Capabilities.htmlunit',
|
117
|
+
'as argument in constructor',
|
118
|
+
id: :caps_browsers)
|
99
119
|
new({
|
100
120
|
browser_name: 'htmlunit'
|
101
121
|
}.merge(opts))
|
102
122
|
end
|
103
123
|
|
104
124
|
def internet_explorer(opts = {})
|
125
|
+
WebDriver.logger.deprecate('Remote::Capabilities.ie', 'Options.ie', id: :caps_browsers)
|
105
126
|
new({
|
106
127
|
browser_name: 'internet explorer',
|
107
128
|
platform_name: :windows
|
108
129
|
}.merge(opts))
|
109
130
|
end
|
110
|
-
|
131
|
+
alias ie internet_explorer
|
111
132
|
|
112
133
|
def always_match(capabilities)
|
113
134
|
new(always_match: capabilities)
|
@@ -134,7 +155,8 @@ module Selenium
|
|
134
155
|
|
135
156
|
# Remote Server Specific
|
136
157
|
if data.key?('webdriver.remote.sessionid')
|
137
|
-
caps[:remote_session_id] =
|
158
|
+
caps[:remote_session_id] =
|
159
|
+
data.delete('webdriver.remote.sessionid')
|
138
160
|
end
|
139
161
|
|
140
162
|
KNOWN.each do |cap|
|
@@ -269,7 +291,7 @@ module Selenium
|
|
269
291
|
as_json == other.as_json
|
270
292
|
end
|
271
293
|
|
272
|
-
|
294
|
+
alias eql? ==
|
273
295
|
|
274
296
|
protected
|
275
297
|
|
@@ -20,7 +20,6 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Remote
|
23
|
-
|
24
23
|
#
|
25
24
|
# https://w3c.github.io/webdriver/#endpoints
|
26
25
|
# @api private
|
@@ -165,7 +164,6 @@ module Selenium
|
|
165
164
|
set_user_verified: [:post, 'session/:session_id/webauthn/authenticator/:authenticatorId/uv']
|
166
165
|
|
167
166
|
}.freeze
|
168
|
-
|
169
167
|
end # Bridge
|
170
168
|
end # Remote
|
171
169
|
end # WebDriver
|
@@ -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
|
@@ -30,17 +29,12 @@ module Selenium
|
|
30
29
|
include DriverExtensions::UploadsFiles
|
31
30
|
include DriverExtensions::HasSessionId
|
32
31
|
|
33
|
-
def initialize(
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
opts[:desired_capabilities] = Remote::Capabilities.__send__(desired_capabilities)
|
41
|
-
end
|
42
|
-
opts[:url] ||= "http://#{Platform.localhost}:4444/wd/hub"
|
43
|
-
super
|
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
|
34
|
+
|
35
|
+
url ||= "http://#{Platform.localhost}:4444/wd/hub"
|
36
|
+
caps = process_options(options, capabilities)
|
37
|
+
super(caps: caps, url: url, **opts)
|
44
38
|
@bridge.file_detector = ->((filename, *)) { File.exist?(filename) && filename.to_s }
|
45
39
|
end
|
46
40
|
|
@@ -52,7 +46,13 @@ module Selenium
|
|
52
46
|
|
53
47
|
def devtools_version
|
54
48
|
capabilities['se:cdpVersion']&.split('.')&.first ||
|
55
|
-
raise(Error::WebDriverError,
|
49
|
+
raise(Error::WebDriverError, 'DevTools is not supported by the Remote Server')
|
50
|
+
end
|
51
|
+
|
52
|
+
def process_options(options, capabilities)
|
53
|
+
raise ArgumentError, "#{self.class} needs :options to be set" if options.nil? && capabilities.nil?
|
54
|
+
|
55
|
+
super(options, capabilities)
|
56
56
|
end
|
57
57
|
end # Driver
|
58
58
|
end # Remote
|
@@ -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
|
@@ -100,6 +100,7 @@ module Selenium
|
|
100
100
|
|
101
101
|
request(:get, URI.parse(response['Location']), DEFAULT_HEADERS.dup, nil, redirects + 1)
|
102
102
|
else
|
103
|
+
WebDriver.logger.debug(" <<< #{response.instance_variable_get(:@header).inspect}")
|
103
104
|
create_response response.code, response.body, response.content_type
|
104
105
|
end
|
105
106
|
end
|
@@ -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,9 +30,29 @@ module Selenium
|
|
31
30
|
DriverExtensions::HasApplePermissions,
|
32
31
|
DriverExtensions::HasWebStorage].freeze
|
33
32
|
|
33
|
+
def initialize(capabilities: nil, options: nil, service: nil, url: nil, **opts)
|
34
|
+
raise ArgumentError, "Can't initialize #{self.class} with :url" if url
|
35
|
+
|
36
|
+
caps = process_options(options, capabilities)
|
37
|
+
url = service_url(service || Service.safari)
|
38
|
+
super(caps: caps, url: url, **opts)
|
39
|
+
end
|
40
|
+
|
34
41
|
def browser
|
35
42
|
:safari
|
36
43
|
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def process_options(options, capabilities)
|
48
|
+
if options && !options.is_a?(Options)
|
49
|
+
raise ArgumentError, ":options must be an instance of #{Options}"
|
50
|
+
elsif options.nil? && capabilities.nil?
|
51
|
+
options = Options.new
|
52
|
+
end
|
53
|
+
|
54
|
+
super(options, capabilities)
|
55
|
+
end
|
37
56
|
end # Driver
|
38
57
|
end # Safari
|
39
58
|
end # WebDriver
|
@@ -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 = Selenium::WebDriver::Safari.technology_preview? ?
|
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
|
@@ -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!
|
@@ -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.freeze
|
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.freeze
|
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.freeze
|
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
|
37
|
+
%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/x.freeze
|
38
38
|
HEX_PATTERN = /#(\h{2})(\h{2})(\h{2})/.freeze
|
39
39
|
HEX3_PATTERN = /#(\h)(\h)(\h)/.freeze
|
40
|
-
HSL_PATTERN =
|
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.freeze
|
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.freeze
|
47
47
|
|
48
48
|
attr_reader :red, :green, :blue, :alpha
|
49
49
|
|
@@ -83,8 +83,8 @@ 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
89
|
r = hue_to_rgb(luminocity1, luminocity2, h + (1.0 / 3.0))
|
90
90
|
g = hue_to_rgb(luminocity1, luminocity2, h)
|
@@ -122,7 +122,7 @@ 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
128
|
[red, green, blue, alpha, self.class].hash
|
@@ -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
|
@@ -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
|
data/lib/selenium/webdriver.rb
CHANGED
@@ -33,9 +33,9 @@ module Selenium
|
|
33
33
|
Point = Struct.new(:x, :y)
|
34
34
|
Dimension = Struct.new(:width, :height)
|
35
35
|
Rectangle = Struct.new(:x, :y, :width, :height)
|
36
|
-
Location = Struct.new(:latitude, :longitude, :altitude)
|
37
36
|
|
38
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,8 @@ module Selenium
|
|
94
94
|
# @return [Logger]
|
95
95
|
#
|
96
96
|
|
97
|
-
def self.logger
|
98
|
-
@logger ||= WebDriver::Logger.new
|
97
|
+
def self.logger(**opts)
|
98
|
+
@logger ||= WebDriver::Logger.new('Selenium', **opts)
|
99
99
|
end
|
100
100
|
end # WebDriver
|
101
101
|
end # Selenium
|
data/selenium-webdriver.gemspec
CHANGED
@@ -55,12 +55,10 @@ Gem::Specification.new do |s|
|
|
55
55
|
|
56
56
|
s.add_development_dependency 'pry', ['~> 0.14']
|
57
57
|
s.add_development_dependency 'rack', ['~> 2.0']
|
58
|
-
s.add_development_dependency 'rake'
|
59
58
|
s.add_development_dependency 'rspec', ['~> 3.0']
|
60
|
-
s.add_development_dependency 'rubocop', ['~> 1.
|
61
|
-
s.add_development_dependency 'rubocop-performance', ['~> 1.
|
62
|
-
s.add_development_dependency 'rubocop-
|
63
|
-
s.add_development_dependency 'rubocop-rspec', ['~> 2.12']
|
59
|
+
s.add_development_dependency 'rubocop', ['~> 1.42']
|
60
|
+
s.add_development_dependency 'rubocop-performance', ['~> 1.15']
|
61
|
+
s.add_development_dependency 'rubocop-rspec', ['~> 2.16']
|
64
62
|
s.add_development_dependency 'webmock', ['~> 3.5']
|
65
63
|
s.add_development_dependency 'webrick', ['~> 1.7']
|
66
64
|
s.add_development_dependency 'yard', ['~> 0.9.11']
|