selenium-webdriver 3.142.7 → 4.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGES +685 -5
- data/Gemfile +6 -1
- data/LICENSE +1 -1
- data/NOTICE +2 -0
- data/README.md +4 -5
- data/bin/linux/selenium-manager +0 -0
- data/bin/macos/selenium-manager +0 -0
- data/bin/windows/selenium-manager.exe +0 -0
- data/lib/selenium/server.rb +93 -90
- data/lib/selenium/webdriver/atoms/findElements.js +122 -0
- data/lib/selenium/webdriver/atoms/getAttribute.js +100 -7
- data/lib/selenium/webdriver/atoms/isDisplayed.js +77 -78
- data/lib/selenium/webdriver/atoms/mutationListener.js +55 -0
- data/lib/selenium/webdriver/atoms.rb +5 -3
- data/lib/selenium/webdriver/bidi/browsing_context.rb +88 -0
- data/lib/selenium/webdriver/bidi/browsing_context_info.rb +35 -0
- data/lib/selenium/webdriver/bidi/log/base_log_entry.rb +35 -0
- data/lib/selenium/webdriver/bidi/log/console_log_entry.rb +35 -0
- data/lib/selenium/webdriver/bidi/log/filter_by.rb +40 -0
- data/lib/selenium/webdriver/bidi/log/generic_log_entry.rb +33 -0
- data/lib/selenium/webdriver/bidi/log/javascript_log_entry.rb +33 -0
- data/lib/selenium/webdriver/bidi/log_inspector.rb +143 -0
- data/lib/selenium/webdriver/bidi/navigate_result.rb +33 -0
- data/lib/selenium/webdriver/bidi/session.rb +51 -0
- data/lib/selenium/webdriver/{common/keyboard.rb → bidi.rb} +21 -35
- data/lib/selenium/webdriver/chrome/driver.rb +9 -86
- data/lib/selenium/webdriver/chrome/features.rb +48 -0
- data/lib/selenium/webdriver/chrome/options.rb +9 -158
- data/lib/selenium/webdriver/chrome/profile.rb +3 -80
- data/lib/selenium/webdriver/chrome/service.rb +7 -29
- data/lib/selenium/webdriver/chrome.rb +5 -20
- data/lib/selenium/webdriver/chromium/driver.rb +60 -0
- data/lib/selenium/webdriver/{chrome/bridge.rb → chromium/features.rb} +48 -17
- data/lib/selenium/webdriver/chromium/options.rb +243 -0
- data/lib/selenium/webdriver/chromium/profile.rb +113 -0
- data/lib/selenium/webdriver/chromium.rb +29 -0
- data/lib/selenium/webdriver/common/action_builder.rb +126 -238
- data/lib/selenium/webdriver/common/child_process.rb +124 -0
- data/lib/selenium/webdriver/common/driver.rb +82 -43
- data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/{has_location.rb → full_page_screenshot.rb} +13 -11
- data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +49 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +87 -0
- data/lib/selenium/webdriver/common/driver_extensions/{has_touch_screen.rb → has_bidi.rb} +9 -9
- data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +86 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_cdp.rb +36 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +42 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +0 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +41 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_file_downloads.rb +65 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +36 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +143 -0
- data/lib/selenium/webdriver/common/driver_extensions/{has_remote_status.rb → has_logs.rb} +4 -4
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +16 -1
- data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +69 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +11 -13
- data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +75 -0
- data/lib/selenium/webdriver/common/driver_extensions/{rotatable.rb → prints_page.rb} +18 -20
- data/lib/selenium/webdriver/common/driver_finder.rb +45 -0
- data/lib/selenium/webdriver/common/element.rb +89 -29
- data/lib/selenium/webdriver/common/error.rb +53 -194
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +2 -2
- data/lib/selenium/webdriver/common/interactions/input_device.rb +10 -4
- data/lib/selenium/webdriver/common/interactions/interaction.rb +12 -22
- data/lib/selenium/webdriver/common/interactions/interactions.rb +24 -4
- data/lib/selenium/webdriver/common/interactions/key_actions.rb +10 -6
- data/lib/selenium/webdriver/common/interactions/key_input.rb +11 -27
- data/lib/selenium/webdriver/common/interactions/none_input.rb +10 -8
- data/lib/selenium/webdriver/common/interactions/pause.rb +49 -0
- data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +71 -82
- data/lib/selenium/webdriver/common/interactions/pointer_cancel.rb +45 -0
- data/lib/selenium/webdriver/common/interactions/pointer_event_properties.rb +63 -0
- data/lib/selenium/webdriver/common/interactions/pointer_input.rb +15 -84
- data/lib/selenium/webdriver/common/interactions/pointer_move.rb +60 -0
- data/lib/selenium/webdriver/common/interactions/pointer_press.rb +85 -0
- data/lib/selenium/webdriver/common/interactions/scroll.rb +59 -0
- data/lib/selenium/webdriver/common/interactions/scroll_origin.rb +48 -0
- data/lib/selenium/webdriver/common/interactions/typing_interaction.rb +54 -0
- data/lib/selenium/webdriver/common/interactions/wheel_actions.rb +113 -0
- data/lib/selenium/webdriver/common/{w3c_manager.rb → interactions/wheel_input.rb} +14 -17
- data/lib/selenium/webdriver/common/keys.rb +1 -0
- data/lib/selenium/webdriver/common/local_driver.rb +46 -0
- data/lib/selenium/webdriver/common/log_entry.rb +2 -2
- data/lib/selenium/webdriver/common/logger.rb +119 -19
- data/lib/selenium/webdriver/common/manager.rb +11 -38
- data/lib/selenium/webdriver/common/options.rb +154 -23
- data/lib/selenium/webdriver/common/platform.rb +15 -52
- data/lib/selenium/webdriver/common/port_prober.rb +4 -6
- data/lib/selenium/webdriver/common/profile_helper.rb +11 -9
- data/lib/selenium/webdriver/common/proxy.rb +8 -5
- data/lib/selenium/webdriver/common/search_context.rb +7 -9
- data/lib/selenium/webdriver/common/selenium_manager.rb +140 -0
- data/lib/selenium/webdriver/common/service.rb +26 -143
- data/lib/selenium/webdriver/common/service_manager.rb +144 -0
- data/lib/selenium/webdriver/common/shadow_root.rb +86 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +4 -4
- data/lib/selenium/webdriver/common/socket_poller.rb +4 -4
- data/lib/selenium/webdriver/common/takes_screenshot.rb +65 -0
- data/lib/selenium/webdriver/common/target_locator.rb +31 -4
- data/lib/selenium/webdriver/common/timeouts.rb +31 -4
- data/lib/selenium/webdriver/common/virtual_authenticator/credential.rb +85 -0
- data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator.rb +72 -0
- data/lib/selenium/webdriver/common/virtual_authenticator/virtual_authenticator_options.rb +62 -0
- data/lib/selenium/webdriver/common/wait.rb +1 -1
- data/lib/selenium/webdriver/common/websocket_connection.rb +164 -0
- data/lib/selenium/webdriver/common/window.rb +6 -10
- data/lib/selenium/webdriver/common/zipper.rb +4 -10
- data/lib/selenium/webdriver/common.rb +43 -20
- data/lib/selenium/webdriver/devtools/console_event.rb +36 -0
- data/lib/selenium/webdriver/devtools/exception_event.rb +34 -0
- data/lib/selenium/webdriver/devtools/mutation_event.rb +35 -0
- data/lib/selenium/webdriver/devtools/network_interceptor.rb +173 -0
- data/lib/selenium/webdriver/devtools/pinned_script.rb +57 -0
- data/lib/selenium/webdriver/devtools/request.rb +65 -0
- data/lib/selenium/webdriver/devtools/response.rb +64 -0
- data/lib/selenium/webdriver/devtools.rb +96 -0
- data/lib/selenium/webdriver/edge/driver.rb +11 -27
- data/lib/selenium/webdriver/edge/features.rb +48 -0
- data/lib/selenium/webdriver/edge/options.rb +18 -43
- data/lib/selenium/webdriver/edge/profile.rb +33 -0
- data/lib/selenium/webdriver/edge/service.rb +8 -23
- data/lib/selenium/webdriver/edge.rb +11 -16
- data/lib/selenium/webdriver/firefox/driver.rb +38 -19
- data/lib/selenium/webdriver/firefox/extension.rb +8 -0
- data/lib/selenium/webdriver/firefox/features.rb +70 -0
- data/lib/selenium/webdriver/firefox/options.rb +73 -61
- data/lib/selenium/webdriver/firefox/profile.rb +20 -72
- data/lib/selenium/webdriver/firefox/service.rb +3 -25
- data/lib/selenium/webdriver/firefox/util.rb +1 -1
- data/lib/selenium/webdriver/firefox.rb +17 -28
- data/lib/selenium/webdriver/ie/driver.rb +5 -45
- data/lib/selenium/webdriver/ie/features.rb +34 -0
- data/lib/selenium/webdriver/ie/options.rb +14 -44
- data/lib/selenium/webdriver/ie/service.rb +3 -27
- data/lib/selenium/webdriver/ie.rb +4 -16
- data/lib/selenium/webdriver/remote/bridge/commands.rb +164 -0
- data/lib/selenium/webdriver/remote/bridge.rb +574 -88
- data/lib/selenium/webdriver/remote/capabilities.rb +144 -158
- data/lib/selenium/webdriver/remote/driver.rb +45 -14
- data/lib/selenium/webdriver/remote/features.rb +75 -0
- data/lib/selenium/webdriver/remote/http/common.rb +3 -8
- data/lib/selenium/webdriver/remote/http/curb.rb +1 -3
- data/lib/selenium/webdriver/remote/http/default.rb +24 -33
- data/lib/selenium/webdriver/remote/response.rb +17 -49
- data/lib/selenium/webdriver/remote/server_error.rb +1 -1
- data/lib/selenium/webdriver/remote.rb +15 -12
- data/lib/selenium/webdriver/safari/driver.rb +7 -29
- data/lib/selenium/webdriver/safari/{bridge.rb → features.rb} +7 -5
- data/lib/selenium/webdriver/safari/options.rb +12 -27
- data/lib/selenium/webdriver/safari/service.rb +13 -11
- data/lib/selenium/webdriver/safari.rb +14 -20
- data/lib/selenium/webdriver/support/block_event_listener.rb +1 -1
- data/lib/selenium/webdriver/support/color.rb +24 -24
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +5 -5
- data/lib/selenium/webdriver/support/guards/guard.rb +90 -0
- data/lib/selenium/webdriver/{firefox/marionette/bridge.rb → support/guards/guard_condition.rb} +21 -20
- data/lib/selenium/webdriver/support/guards.rb +95 -0
- data/lib/selenium/webdriver/support/relative_locator.rb +50 -0
- data/lib/selenium/webdriver/support/select.rb +6 -4
- data/lib/selenium/webdriver/support.rb +1 -0
- data/lib/selenium/webdriver/version.rb +1 -1
- data/lib/selenium/webdriver.rb +19 -17
- data/selenium-webdriver.gemspec +36 -18
- metadata +161 -91
- data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +0 -58
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +0 -64
- data/lib/selenium/webdriver/common/mouse.rb +0 -89
- data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -78
- data/lib/selenium/webdriver/common/touch_screen.rb +0 -123
- data/lib/selenium/webdriver/common/w3c_action_builder.rb +0 -212
- data/lib/selenium/webdriver/edge/bridge.rb +0 -76
- data/lib/selenium/webdriver/firefox/binary.rb +0 -187
- data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/launcher.rb +0 -111
- data/lib/selenium/webdriver/firefox/legacy/driver.rb +0 -83
- data/lib/selenium/webdriver/firefox/marionette/driver.rb +0 -90
- data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
- data/lib/selenium/webdriver/remote/http/persistent.rb +0 -60
- data/lib/selenium/webdriver/remote/oss/bridge.rb +0 -594
- data/lib/selenium/webdriver/remote/oss/commands.rb +0 -223
- data/lib/selenium/webdriver/remote/w3c/bridge.rb +0 -605
- data/lib/selenium/webdriver/remote/w3c/capabilities.rb +0 -310
- data/lib/selenium/webdriver/remote/w3c/commands.rb +0 -157
@@ -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
|
@@ -28,8 +26,7 @@ module Selenium
|
|
28
26
|
class Default < Common
|
29
27
|
attr_writer :proxy
|
30
28
|
|
31
|
-
attr_accessor :open_timeout
|
32
|
-
attr_accessor :read_timeout
|
29
|
+
attr_accessor :open_timeout, :read_timeout
|
33
30
|
|
34
31
|
# Initializes object.
|
35
32
|
# Warning: Setting {#open_timeout} to non-nil values will cause a separate thread to spawn.
|
@@ -39,15 +36,7 @@ module Selenium
|
|
39
36
|
def initialize(open_timeout: nil, read_timeout: nil)
|
40
37
|
@open_timeout = open_timeout
|
41
38
|
@read_timeout = read_timeout
|
42
|
-
|
43
|
-
|
44
|
-
# Maintaining backward compatibility.
|
45
|
-
# @param [Numeric] value - Timeout in seconds to apply to both open timeout and read timeouts.
|
46
|
-
# @deprecated Please set the specific desired timeout {#read_timeout} or {#open_timeout} directly.
|
47
|
-
def timeout=(value)
|
48
|
-
WebDriver.logger.deprecate ':timeout=', '#read_timeout= and #open_timeout='
|
49
|
-
self.open_timeout = value
|
50
|
-
self.read_timeout = value
|
39
|
+
super()
|
51
40
|
end
|
52
41
|
|
53
42
|
def close
|
@@ -64,14 +53,18 @@ module Selenium
|
|
64
53
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
65
54
|
end
|
66
55
|
|
67
|
-
|
68
|
-
http.open_timeout = open_timeout
|
56
|
+
http.open_timeout = open_timeout if open_timeout
|
69
57
|
http.read_timeout = read_timeout if read_timeout
|
70
58
|
|
71
|
-
http
|
59
|
+
start(http)
|
60
|
+
http
|
72
61
|
end
|
73
62
|
end
|
74
63
|
|
64
|
+
def start(http)
|
65
|
+
http.start
|
66
|
+
end
|
67
|
+
|
75
68
|
MAX_RETRIES = 3
|
76
69
|
|
77
70
|
def request(verb, url, headers, payload, redirects = 0)
|
@@ -80,9 +73,10 @@ module Selenium
|
|
80
73
|
begin
|
81
74
|
request = new_request_for(verb, url, headers, payload)
|
82
75
|
response = response_for(request)
|
83
|
-
rescue Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EADDRINUSE
|
84
|
-
# a retry is sometimes needed
|
85
|
-
# 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
|
86
80
|
#
|
87
81
|
# A more robust solution is bumping the MaxUserPort setting
|
88
82
|
# as described here:
|
@@ -93,24 +87,19 @@ module Selenium
|
|
93
87
|
retries += 1
|
94
88
|
sleep 2
|
95
89
|
retry
|
96
|
-
rescue Errno::
|
97
|
-
|
98
|
-
raise if retries >= MAX_RETRIES
|
99
|
-
|
100
|
-
retries += 1
|
101
|
-
sleep 2
|
102
|
-
retry
|
103
|
-
rescue Errno::ECONNREFUSED => ex
|
104
|
-
raise ex.class, "using proxy: #{proxy.http}" if use_proxy?
|
90
|
+
rescue Errno::ECONNREFUSED => e
|
91
|
+
raise e.class, "using proxy: #{proxy.http}" if use_proxy?
|
105
92
|
|
106
93
|
raise
|
107
94
|
end
|
108
95
|
|
109
96
|
if response.is_a? Net::HTTPRedirection
|
97
|
+
WebDriver.logger.debug("Redirect to #{response['Location']}; times: #{redirects}")
|
110
98
|
raise Error::WebDriverError, 'too many redirects' if redirects >= MAX_REDIRECTS
|
111
99
|
|
112
100
|
request(:get, URI.parse(response['Location']), DEFAULT_HEADERS.dup, nil, redirects + 1)
|
113
101
|
else
|
102
|
+
WebDriver.logger.debug(" <<< #{response.instance_variable_get(:@header).inspect}", id: :header)
|
114
103
|
create_response response.code, response.body, response.content_type
|
115
104
|
end
|
116
105
|
end
|
@@ -132,12 +121,14 @@ module Selenium
|
|
132
121
|
def new_http_client
|
133
122
|
if use_proxy?
|
134
123
|
url = @proxy.http
|
135
|
-
|
124
|
+
unless proxy.respond_to?(:http) && url
|
125
|
+
raise Error::WebDriverError,
|
126
|
+
"expected HTTP proxy, got #{@proxy.inspect}"
|
127
|
+
end
|
136
128
|
|
137
129
|
proxy = URI.parse(url)
|
138
130
|
|
139
|
-
|
140
|
-
clazz.new(server_url.host, server_url.port)
|
131
|
+
Net::HTTP.new(server_url.host, server_url.port, proxy.host, proxy.port, proxy.user, proxy.password)
|
141
132
|
else
|
142
133
|
Net::HTTP.new server_url.host, server_url.port
|
143
134
|
end
|
@@ -145,8 +136,8 @@ module Selenium
|
|
145
136
|
|
146
137
|
def proxy
|
147
138
|
@proxy ||= begin
|
148
|
-
proxy = ENV
|
149
|
-
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)
|
150
141
|
|
151
142
|
if proxy
|
152
143
|
proxy = "http://#{proxy}" unless proxy.start_with?('http://')
|
@@ -20,12 +20,12 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Remote
|
23
|
+
#
|
23
24
|
# @api private
|
24
|
-
|
25
|
-
STACKTRACE_KEY = 'stackTrace'
|
25
|
+
#
|
26
26
|
|
27
|
+
class Response
|
27
28
|
attr_reader :code, :payload
|
28
|
-
attr_writer :payload
|
29
29
|
|
30
30
|
def initialize(code, payload = nil)
|
31
31
|
@code = code
|
@@ -35,33 +35,16 @@ module Selenium
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def error
|
38
|
-
|
38
|
+
error, message, backtrace = process_error
|
39
|
+
klass = Error.for_error(error) || return
|
39
40
|
|
40
|
-
ex = klass.new(
|
41
|
+
ex = klass.new(message)
|
41
42
|
ex.set_backtrace(caller)
|
42
|
-
add_backtrace ex
|
43
|
+
add_backtrace ex, backtrace
|
43
44
|
|
44
45
|
ex
|
45
46
|
end
|
46
47
|
|
47
|
-
def error_message
|
48
|
-
val = value
|
49
|
-
|
50
|
-
case val
|
51
|
-
when Hash
|
52
|
-
msg = val['message']
|
53
|
-
return 'unknown error' unless msg
|
54
|
-
|
55
|
-
msg << ": #{val['alert']['text'].inspect}" if val['alert'].is_a?(Hash) && val['alert']['text']
|
56
|
-
msg << " (#{val['class']})" if val['class']
|
57
|
-
msg
|
58
|
-
when String
|
59
|
-
val
|
60
|
-
else
|
61
|
-
"unknown error, status=#{status}: #{val.inspect}"
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
48
|
def [](key)
|
66
49
|
@payload[key]
|
67
50
|
end
|
@@ -76,14 +59,7 @@ module Selenium
|
|
76
59
|
raise Error::ServerError, self
|
77
60
|
end
|
78
61
|
|
79
|
-
def add_backtrace(ex)
|
80
|
-
return unless error_payload.is_a?(Hash)
|
81
|
-
|
82
|
-
# Legacy Firefox returns String in ['value'], while we expect Hash.
|
83
|
-
# Use #dig when Firefox legacy is removed (4.0).
|
84
|
-
server_trace = error_payload[STACKTRACE_KEY] ||
|
85
|
-
error_payload[STACKTRACE_KEY.downcase] ||
|
86
|
-
(error_payload['value'] && error_payload['value'][STACKTRACE_KEY])
|
62
|
+
def add_backtrace(ex, server_trace)
|
87
63
|
return unless server_trace
|
88
64
|
|
89
65
|
backtrace = case server_trace
|
@@ -97,7 +73,7 @@ module Selenium
|
|
97
73
|
end
|
98
74
|
|
99
75
|
def backtrace_from_remote(server_trace)
|
100
|
-
server_trace.
|
76
|
+
server_trace.filter_map do |frame|
|
101
77
|
next unless frame.is_a?(Hash)
|
102
78
|
|
103
79
|
file = frame['fileName']
|
@@ -110,25 +86,17 @@ module Selenium
|
|
110
86
|
meth = 'unknown' if meth.nil? || meth.empty?
|
111
87
|
|
112
88
|
"[remote server] #{file}:#{line}:in `#{meth}'"
|
113
|
-
|
114
|
-
end
|
115
|
-
|
116
|
-
def error_payload
|
117
|
-
# Even errors are wrapped in 'value' for w3c
|
118
|
-
# Grab 'value' key for error, leave original payload alone and let the bridge process
|
119
|
-
@error_payload ||= !@payload.key?('sessionId') ? @payload['value'] : @payload
|
120
|
-
end
|
121
|
-
|
122
|
-
def status
|
123
|
-
return unless error_payload.is_a? Hash
|
124
|
-
|
125
|
-
@status ||= error_payload['status'] || error_payload['error']
|
89
|
+
end
|
126
90
|
end
|
127
91
|
|
128
|
-
def
|
129
|
-
return unless
|
92
|
+
def process_error
|
93
|
+
return unless self['value'].is_a?(Hash)
|
130
94
|
|
131
|
-
|
95
|
+
[
|
96
|
+
self['value']['error'],
|
97
|
+
self['value']['message'],
|
98
|
+
self['value']['stacktrace']
|
99
|
+
]
|
132
100
|
end
|
133
101
|
end # Response
|
134
102
|
end # Remote
|
@@ -18,18 +18,21 @@
|
|
18
18
|
# under the License.
|
19
19
|
|
20
20
|
require 'uri'
|
21
|
-
|
22
|
-
require 'selenium/webdriver/remote/bridge'
|
23
|
-
require 'selenium/webdriver/remote/driver'
|
24
|
-
require 'selenium/webdriver/remote/response'
|
25
21
|
require 'selenium/webdriver/remote/server_error'
|
26
|
-
require 'selenium/webdriver/remote/http/common'
|
27
|
-
require 'selenium/webdriver/remote/http/default'
|
28
22
|
|
29
|
-
|
30
|
-
|
31
|
-
|
23
|
+
module Selenium
|
24
|
+
module WebDriver
|
25
|
+
module Remote
|
26
|
+
autoload :Features, 'selenium/webdriver/remote/features'
|
27
|
+
autoload :Bridge, 'selenium/webdriver/remote/bridge'
|
28
|
+
autoload :Driver, 'selenium/webdriver/remote/driver'
|
29
|
+
autoload :Response, 'selenium/webdriver/remote/response'
|
30
|
+
autoload :Capabilities, 'selenium/webdriver/remote/capabilities'
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
module Http
|
33
|
+
autoload :Common, 'selenium/webdriver/remote/http/common'
|
34
|
+
autoload :Default, 'selenium/webdriver/remote/http/default'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -20,48 +20,26 @@
|
|
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
|
27
26
|
#
|
28
27
|
|
29
28
|
class Driver < WebDriver::Driver
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
def initialize(opts = {})
|
35
|
-
opts[:desired_capabilities] = create_capabilities(opts)
|
36
|
-
|
37
|
-
opts[:url] ||= service_url(opts)
|
29
|
+
EXTENSIONS = [DriverExtensions::HasDebugger,
|
30
|
+
DriverExtensions::HasApplePermissions,
|
31
|
+
DriverExtensions::HasWebStorage].freeze
|
38
32
|
|
39
|
-
|
40
|
-
@bridge = Remote::Bridge.handshake(**opts)
|
41
|
-
@bridge.extend Bridge
|
33
|
+
include LocalDriver
|
42
34
|
|
43
|
-
|
35
|
+
def initialize(options: nil, service: nil, url: nil, **opts)
|
36
|
+
caps, url = initialize_local_driver(options, service, url)
|
37
|
+
super(caps: caps, url: url, **opts)
|
44
38
|
end
|
45
39
|
|
46
40
|
def browser
|
47
41
|
:safari
|
48
42
|
end
|
49
|
-
|
50
|
-
def quit
|
51
|
-
super
|
52
|
-
ensure
|
53
|
-
@service&.stop
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def create_capabilities(opts = {})
|
59
|
-
caps = opts.delete(:desired_capabilities) { Remote::Capabilities.safari }
|
60
|
-
options = opts.delete(:options) { Options.new }
|
61
|
-
caps.merge!(options.as_json)
|
62
|
-
caps
|
63
|
-
end
|
64
|
-
|
65
43
|
end # Driver
|
66
44
|
end # Safari
|
67
45
|
end # WebDriver
|
@@ -20,17 +20,20 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Safari
|
23
|
-
module
|
24
|
-
|
23
|
+
module Features
|
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'],
|
28
27
|
set_permissions: [:post, 'session/:session_id/apple/permissions'],
|
29
28
|
attach_debugger: [:post, 'session/:session_id/apple/attach_debugger']
|
30
29
|
}.freeze
|
31
30
|
|
31
|
+
def command_list
|
32
|
+
SAFARI_COMMANDS.merge(self.class::COMMANDS)
|
33
|
+
end
|
34
|
+
|
32
35
|
def commands(command)
|
33
|
-
|
36
|
+
command_list[command]
|
34
37
|
end
|
35
38
|
|
36
39
|
def permissions
|
@@ -44,7 +47,6 @@ module Selenium
|
|
44
47
|
def attach_debugger
|
45
48
|
execute :attach_debugger, {}, {}
|
46
49
|
end
|
47
|
-
|
48
50
|
end # Bridge
|
49
51
|
end # Safari
|
50
52
|
end # WebDriver
|
@@ -20,39 +20,24 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Safari
|
23
|
-
class Options
|
24
|
-
attr_accessor :
|
23
|
+
class Options < WebDriver::Options
|
24
|
+
attr_accessor :options
|
25
25
|
|
26
|
-
#
|
27
|
-
# Create a new Options instance for W3C-capable versions of Safari.
|
28
|
-
#
|
29
|
-
# @example
|
30
|
-
# options = Selenium::WebDriver::Safari::Options.new(automatic_inspection: true)
|
31
|
-
# driver = Selenium::WebDriver.for :safari, options: options
|
32
|
-
#
|
33
|
-
# @param [Hash] opts the pre-defined options to create the Safari::Options with
|
34
|
-
# @option opts [Boolean] :automatic_inspection Preloads Web Inspector and JavaScript debugger. Default is false
|
35
|
-
# @option opts [Boolean] :automatic_profiling Preloads Web Inspector and starts a timeline recording. Default is false
|
36
|
-
#
|
37
26
|
# @see https://developer.apple.com/documentation/webkit/about_webdriver_for_safari
|
38
|
-
|
27
|
+
CAPABILITIES = {automatic_inspection: 'safari:automaticInspection',
|
28
|
+
automatic_profiling: 'safari:automaticProfiling'}.freeze
|
29
|
+
BROWSER = Selenium::WebDriver::Safari.technology_preview? ? 'Safari Technology Preview' : 'safari'
|
39
30
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
end
|
31
|
+
def add_option(name, value = nil)
|
32
|
+
key = name.is_a?(Hash) ? name.keys.first : name
|
33
|
+
raise ArgumentError, 'Safari does not support options that are not namespaced' unless key.to_s.include?(':')
|
44
34
|
|
45
|
-
|
46
|
-
|
47
|
-
#
|
35
|
+
super
|
36
|
+
end
|
48
37
|
|
49
38
|
def as_json(*)
|
50
|
-
|
51
|
-
|
52
|
-
opts['safari:automaticInspection'] = true if @automatic_inspection
|
53
|
-
opts['safari:automaticProfiling'] = true if @automatic_profiling
|
54
|
-
|
55
|
-
opts
|
39
|
+
@options[:browser_name] = Safari.technology_preview? ? 'Safari Technology Preview' : 'safari'
|
40
|
+
super
|
56
41
|
end
|
57
42
|
end # Options
|
58
43
|
end # Safari
|
@@ -20,18 +20,20 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Safari
|
23
|
-
#
|
24
|
-
# @api private
|
25
|
-
#
|
26
|
-
|
27
23
|
class Service < WebDriver::Service
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
DEFAULT_PORT = 7050
|
25
|
+
EXECUTABLE = 'safaridriver'
|
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
|
35
37
|
end # Service
|
36
38
|
end # Safari
|
37
39
|
end # WebDriver
|
@@ -17,20 +17,28 @@
|
|
17
17
|
# specific language governing permissions and limitations
|
18
18
|
# under the License.
|
19
19
|
|
20
|
-
require 'selenium/webdriver/safari/bridge'
|
21
|
-
require 'selenium/webdriver/safari/driver'
|
22
|
-
require 'selenium/webdriver/safari/options'
|
23
|
-
|
24
20
|
module Selenium
|
25
21
|
module WebDriver
|
26
22
|
module Safari
|
23
|
+
autoload :Features, 'selenium/webdriver/safari/features'
|
24
|
+
autoload :Driver, 'selenium/webdriver/safari/driver'
|
25
|
+
autoload :Options, 'selenium/webdriver/safari/options'
|
26
|
+
autoload :Service, 'selenium/webdriver/safari/service'
|
27
|
+
|
27
28
|
class << self
|
29
|
+
attr_accessor :use_technology_preview
|
30
|
+
|
28
31
|
def technology_preview
|
29
|
-
|
32
|
+
'/Applications/Safari Technology Preview.app/Contents/MacOS/safaridriver'
|
30
33
|
end
|
31
34
|
|
32
35
|
def technology_preview!
|
33
|
-
|
36
|
+
Service.driver_path = technology_preview
|
37
|
+
@use_technology_preview = true
|
38
|
+
end
|
39
|
+
|
40
|
+
def technology_preview?
|
41
|
+
use_technology_preview
|
34
42
|
end
|
35
43
|
|
36
44
|
def path=(path)
|
@@ -45,21 +53,7 @@ module Selenium
|
|
45
53
|
|
46
54
|
raise Error::WebDriverError, 'Unable to find Safari'
|
47
55
|
end
|
48
|
-
|
49
|
-
def driver_path=(path)
|
50
|
-
WebDriver.logger.deprecate 'Selenium::WebDriver::Safari#driver_path=',
|
51
|
-
'Selenium::WebDriver::Safari::Service#driver_path='
|
52
|
-
Selenium::WebDriver::Safari::Service.driver_path = path
|
53
|
-
end
|
54
|
-
|
55
|
-
def driver_path
|
56
|
-
WebDriver.logger.deprecate 'Selenium::WebDriver::Safari#driver_path',
|
57
|
-
'Selenium::WebDriver::Safari::Service#driver_path'
|
58
|
-
Selenium::WebDriver::Safari::Service.driver_path
|
59
|
-
end
|
60
56
|
end
|
61
57
|
end # Safari
|
62
58
|
end # WebDriver
|
63
59
|
end # Selenium
|
64
|
-
|
65
|
-
require 'selenium/webdriver/safari/service'
|
@@ -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
|
@@ -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
|
|
@@ -72,7 +72,7 @@ module Selenium
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
def self.from_hsl(h, s, l, a) # rubocop:disable Naming/
|
75
|
+
def self.from_hsl(h, s, l, a) # rubocop:disable Naming/MethodParameterName
|
76
76
|
h = Float(h) / 360
|
77
77
|
s = Float(s) / 100
|
78
78
|
l = Float(l) / 100
|
@@ -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
|
@@ -138,7 +138,7 @@ module Selenium
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def hex
|
141
|
-
format '
|
141
|
+
format '#%<red>02x%<green>02x%<blue>02x', red: red, green: green, blue: blue
|
142
142
|
end
|
143
143
|
end # Color
|
144
144
|
end # Support
|
@@ -76,7 +76,7 @@ module Selenium
|
|
76
76
|
@delegate.find_element_by how, what, parent
|
77
77
|
end
|
78
78
|
|
79
|
-
Element.new self, e.ref
|
79
|
+
Element.new self, e.ref.last
|
80
80
|
end
|
81
81
|
|
82
82
|
def find_elements_by(how, what, parent = nil)
|
@@ -84,7 +84,7 @@ module Selenium
|
|
84
84
|
@delegate.find_elements_by(how, what, parent)
|
85
85
|
end
|
86
86
|
|
87
|
-
es.map { |e| Element.new self, e.ref }
|
87
|
+
es.map { |e| Element.new self, e.ref.last }
|
88
88
|
end
|
89
89
|
|
90
90
|
def execute_script(script, *args)
|
@@ -109,7 +109,7 @@ module Selenium
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def driver
|
112
|
-
@driver ||= Driver.new(self)
|
112
|
+
@driver ||= Driver.new(bridge: self)
|
113
113
|
end
|
114
114
|
|
115
115
|
def dispatch(name, *args)
|
@@ -120,8 +120,8 @@ module Selenium
|
|
120
120
|
returned
|
121
121
|
end
|
122
122
|
|
123
|
-
def method_missing(meth,
|
124
|
-
@delegate.__send__(meth,
|
123
|
+
def method_missing(meth, ...) # rubocop:disable Style/MissingRespondToMissing
|
124
|
+
@delegate.__send__(meth, ...)
|
125
125
|
end
|
126
126
|
end # EventFiringBridge
|
127
127
|
end # Support
|