selenium-webdriver 2.45.0 → 3.142.7
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 +7 -0
- data/CHANGES +795 -3
- data/Gemfile +2 -0
- data/{COPYING → LICENSE} +1 -3
- data/README.md +13 -9
- data/lib/selenium/server.rb +93 -71
- data/lib/selenium/webdriver/atoms/getAttribute.js +7 -0
- data/lib/selenium/webdriver/atoms/isDisplayed.js +102 -0
- data/lib/selenium/webdriver/atoms.rb +37 -0
- data/lib/selenium/webdriver/chrome/bridge.rb +47 -99
- data/lib/selenium/webdriver/chrome/driver.rb +127 -0
- data/lib/selenium/webdriver/chrome/options.rb +190 -0
- data/lib/selenium/webdriver/chrome/profile.rb +40 -20
- data/lib/selenium/webdriver/chrome/service.rb +46 -62
- data/lib/selenium/webdriver/chrome.rb +34 -6
- data/lib/selenium/webdriver/common/action_builder.rb +69 -56
- data/lib/selenium/webdriver/common/alert.rb +25 -8
- data/lib/selenium/webdriver/common/bridge_helper.rb +35 -20
- data/lib/selenium/webdriver/common/driver.rb +90 -63
- data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +45 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +50 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +42 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +26 -11
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +58 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +23 -6
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +19 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +24 -7
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +19 -3
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +23 -7
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +26 -5
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +20 -6
- data/lib/selenium/webdriver/common/element.rb +79 -37
- data/lib/selenium/webdriver/common/error.rb +282 -106
- data/lib/selenium/webdriver/common/file_reaper.rb +23 -12
- data/lib/selenium/webdriver/common/html5/local_storage.rb +29 -12
- data/lib/selenium/webdriver/common/html5/session_storage.rb +29 -12
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +29 -18
- data/lib/selenium/webdriver/common/interactions/input_device.rb +54 -0
- data/lib/selenium/webdriver/common/interactions/interaction.rb +53 -0
- data/lib/selenium/webdriver/common/interactions/interactions.rb +43 -0
- data/lib/selenium/webdriver/common/interactions/key_actions.rb +145 -0
- data/lib/selenium/webdriver/common/interactions/key_input.rb +66 -0
- data/lib/selenium/webdriver/common/interactions/none_input.rb +36 -0
- data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +363 -0
- data/lib/selenium/webdriver/common/interactions/pointer_input.rb +139 -0
- data/lib/selenium/webdriver/common/keyboard.rb +27 -12
- data/lib/selenium/webdriver/common/keys.rb +118 -81
- data/lib/selenium/webdriver/common/log_entry.rb +27 -8
- data/lib/selenium/webdriver/common/logger.rb +115 -0
- data/lib/selenium/webdriver/common/logs.rb +24 -7
- data/lib/selenium/webdriver/common/manager.rb +177 -0
- data/lib/selenium/webdriver/common/mouse.rb +29 -12
- data/lib/selenium/webdriver/common/navigation.rb +21 -4
- data/lib/selenium/webdriver/common/options.rb +43 -126
- data/lib/selenium/webdriver/common/platform.rb +101 -97
- data/lib/selenium/webdriver/common/port_prober.rb +24 -17
- data/lib/selenium/webdriver/common/profile_helper.rb +27 -11
- data/lib/selenium/webdriver/common/proxy.rb +86 -73
- data/lib/selenium/webdriver/common/search_context.rb +49 -33
- data/lib/selenium/webdriver/common/service.rb +219 -0
- data/lib/selenium/webdriver/common/socket_lock.rb +82 -0
- data/lib/selenium/webdriver/common/socket_poller.rb +47 -26
- data/lib/selenium/webdriver/common/target_locator.rb +35 -14
- data/lib/selenium/webdriver/common/timeouts.rb +23 -6
- data/lib/selenium/webdriver/common/touch_action_builder.rb +25 -11
- data/lib/selenium/webdriver/common/touch_screen.rb +42 -24
- data/lib/selenium/webdriver/common/w3c_action_builder.rb +212 -0
- data/lib/selenium/webdriver/common/w3c_manager.rb +45 -0
- data/lib/selenium/webdriver/common/wait.rb +34 -14
- data/lib/selenium/webdriver/common/window.rb +75 -16
- data/lib/selenium/webdriver/common/zipper.rb +26 -11
- data/lib/selenium/webdriver/common.rb +40 -7
- data/lib/selenium/webdriver/edge/bridge.rb +76 -0
- data/lib/selenium/webdriver/edge/driver.rb +66 -0
- data/lib/selenium/webdriver/edge/options.rb +80 -0
- data/lib/selenium/webdriver/edge/service.rb +52 -0
- data/lib/selenium/webdriver/edge.rb +44 -0
- data/lib/selenium/webdriver/firefox/binary.rb +70 -48
- data/lib/selenium/webdriver/firefox/driver.rb +50 -0
- data/lib/selenium/webdriver/firefox/extension/prefs.json +14 -13
- data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
- data/lib/selenium/webdriver/firefox/extension.rb +50 -19
- data/lib/selenium/webdriver/firefox/launcher.rb +33 -28
- data/lib/selenium/webdriver/firefox/legacy/driver.rb +83 -0
- data/lib/selenium/webdriver/firefox/marionette/bridge.rb +49 -0
- data/lib/selenium/webdriver/firefox/marionette/driver.rb +90 -0
- data/lib/selenium/webdriver/firefox/options.rb +162 -0
- data/lib/selenium/webdriver/firefox/profile.rb +66 -48
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +28 -16
- data/lib/selenium/webdriver/firefox/service.rb +52 -0
- data/lib/selenium/webdriver/firefox/util.rb +19 -2
- data/lib/selenium/webdriver/firefox.rb +46 -10
- data/lib/selenium/webdriver/ie/driver.rb +85 -0
- data/lib/selenium/webdriver/ie/options.rb +138 -0
- data/lib/selenium/webdriver/ie/service.rb +54 -0
- data/lib/selenium/webdriver/ie.rb +32 -10
- data/lib/selenium/webdriver/remote/bridge.rb +117 -572
- data/lib/selenium/webdriver/remote/capabilities.rb +116 -99
- data/lib/selenium/webdriver/remote/driver.rb +51 -0
- data/lib/selenium/webdriver/remote/http/common.rb +54 -23
- data/lib/selenium/webdriver/remote/http/curb.rb +30 -12
- data/lib/selenium/webdriver/remote/http/default.rb +85 -42
- data/lib/selenium/webdriver/remote/http/persistent.rb +29 -7
- data/lib/selenium/webdriver/remote/oss/bridge.rb +594 -0
- data/lib/selenium/webdriver/remote/oss/commands.rb +223 -0
- data/lib/selenium/webdriver/remote/response.rb +68 -30
- data/lib/selenium/webdriver/remote/server_error.rb +22 -5
- data/lib/selenium/webdriver/remote/w3c/bridge.rb +605 -0
- data/lib/selenium/webdriver/remote/w3c/capabilities.rb +310 -0
- data/lib/selenium/webdriver/remote/w3c/commands.rb +157 -0
- data/lib/selenium/webdriver/remote.rb +27 -13
- data/lib/selenium/webdriver/safari/bridge.rb +38 -107
- data/lib/selenium/webdriver/safari/driver.rb +68 -0
- data/lib/selenium/webdriver/safari/options.rb +56 -75
- data/lib/selenium/webdriver/safari/service.rb +38 -0
- data/lib/selenium/webdriver/safari.rb +49 -31
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +40 -6
- data/lib/selenium/webdriver/support/block_event_listener.rb +24 -7
- data/lib/selenium/webdriver/support/color.rb +82 -46
- data/lib/selenium/webdriver/support/escaper.rb +43 -0
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +56 -39
- data/lib/selenium/webdriver/support/select.rb +66 -89
- data/lib/selenium/webdriver/support.rb +20 -0
- data/lib/selenium/webdriver/version.rb +24 -0
- data/lib/selenium/webdriver.rb +55 -25
- data/lib/selenium-webdriver.rb +19 -0
- data/selenium-webdriver.gemspec +42 -29
- metadata +331 -260
- data/Gemfile.lock +0 -48
- data/lib/selenium/client/base.rb +0 -132
- data/lib/selenium/client/driver.rb +0 -10
- data/lib/selenium/client/errors.rb +0 -9
- data/lib/selenium/client/extensions.rb +0 -118
- data/lib/selenium/client/idiomatic.rb +0 -488
- data/lib/selenium/client/javascript_expression_builder.rb +0 -116
- data/lib/selenium/client/javascript_frameworks/jquery.rb +0 -13
- data/lib/selenium/client/javascript_frameworks/prototype.rb +0 -13
- data/lib/selenium/client/legacy_driver.rb +0 -1720
- data/lib/selenium/client/protocol.rb +0 -104
- data/lib/selenium/client/selenium_helper.rb +0 -34
- data/lib/selenium/client.rb +0 -38
- data/lib/selenium/rake/server_task.rb +0 -157
- data/lib/selenium/webdriver/android/bridge.rb +0 -49
- data/lib/selenium/webdriver/android.rb +0 -9
- data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -9
- data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -42
- data/lib/selenium/webdriver/common/core_ext/string.rb +0 -5
- data/lib/selenium/webdriver/common/driver_extensions/has_browser_connection.rb +0 -17
- data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +0 -39
- data/lib/selenium/webdriver/common/html5/location.rb +0 -0
- data/lib/selenium/webdriver/common/json_helper.rb +0 -34
- data/lib/selenium/webdriver/firefox/bridge.rb +0 -70
- data/lib/selenium/webdriver/firefox/socket_lock.rb +0 -61
- data/lib/selenium/webdriver/ie/bridge.rb +0 -69
- data/lib/selenium/webdriver/ie/server.rb +0 -90
- data/lib/selenium/webdriver/iphone/bridge.rb +0 -45
- data/lib/selenium/webdriver/iphone.rb +0 -9
- data/lib/selenium/webdriver/opera/bridge.rb +0 -112
- data/lib/selenium/webdriver/opera/service.rb +0 -49
- data/lib/selenium/webdriver/opera.rb +0 -24
- data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -59
- data/lib/selenium/webdriver/phantomjs/service.rb +0 -90
- data/lib/selenium/webdriver/phantomjs.rb +0 -22
- data/lib/selenium/webdriver/remote/commands.rb +0 -192
- data/lib/selenium/webdriver/safari/browser.rb +0 -20
- data/lib/selenium/webdriver/safari/extensions.rb +0 -170
- data/lib/selenium/webdriver/safari/resources/SafariDriver.safariextz +0 -0
- data/lib/selenium/webdriver/safari/resources/client.js +0 -6903
- data/lib/selenium/webdriver/safari/server.rb +0 -145
- data/lib/selenium-client.rb +0 -2
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
|
5
|
+
# distributed with this work for additional information
|
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
|
8
|
+
# "License"); you may not use this file except in compliance
|
|
9
|
+
# with the License. You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
|
14
|
+
# software distributed under the License is distributed on an
|
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
# KIND, either express or implied. See the License for the
|
|
17
|
+
# specific language governing permissions and limitations
|
|
18
|
+
# under the License.
|
|
19
|
+
|
|
20
|
+
module Selenium
|
|
21
|
+
module WebDriver
|
|
22
|
+
module Safari
|
|
23
|
+
|
|
24
|
+
#
|
|
25
|
+
# Driver implementation for Safari.
|
|
26
|
+
# @api private
|
|
27
|
+
#
|
|
28
|
+
|
|
29
|
+
class Driver < WebDriver::Driver
|
|
30
|
+
include DriverExtensions::HasDebugger
|
|
31
|
+
include DriverExtensions::HasPermissions
|
|
32
|
+
include DriverExtensions::TakesScreenshot
|
|
33
|
+
|
|
34
|
+
def initialize(opts = {})
|
|
35
|
+
opts[:desired_capabilities] = create_capabilities(opts)
|
|
36
|
+
|
|
37
|
+
opts[:url] ||= service_url(opts)
|
|
38
|
+
|
|
39
|
+
listener = opts.delete(:listener)
|
|
40
|
+
@bridge = Remote::Bridge.handshake(**opts)
|
|
41
|
+
@bridge.extend Bridge
|
|
42
|
+
|
|
43
|
+
super(@bridge, listener: listener)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def browser
|
|
47
|
+
:safari
|
|
48
|
+
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
|
+
end # Driver
|
|
66
|
+
end # Safari
|
|
67
|
+
end # WebDriver
|
|
68
|
+
end # Selenium
|
|
@@ -1,79 +1,60 @@
|
|
|
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
|
+
|
|
1
20
|
module Selenium
|
|
2
21
|
module WebDriver
|
|
3
22
|
module Safari
|
|
4
23
|
class Options
|
|
5
|
-
attr_accessor :
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
private
|
|
43
|
-
|
|
44
|
-
def extensions_as_json
|
|
45
|
-
@extensions.map do |path|
|
|
46
|
-
{'filename' => path.basename, 'contents' => Base64.strict_encode64(path.read) }
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def extract_options(opts)
|
|
51
|
-
@port = Integer(opts[:port] || PortProber.random)
|
|
52
|
-
@data_dir = opts[:custom_data_dir] || opts[:data_dir]
|
|
53
|
-
@clean_session = opts[:clean_session]
|
|
54
|
-
|
|
55
|
-
Array(opts[:extensions]).each { |ext| add_extension(ext) }
|
|
56
|
-
|
|
57
|
-
if opts.key?(:install_extension)
|
|
58
|
-
@skip_extension_installation = !opts[:install_extension]
|
|
59
|
-
elsif opts.key?(:skip_extension_installation)
|
|
60
|
-
@skip_extension_installation = opts[:skip_extension_installation]
|
|
61
|
-
else
|
|
62
|
-
@skip_extension_installation = false
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def verify_safari_extension(path)
|
|
67
|
-
pn = Pathname.new(path)
|
|
68
|
-
|
|
69
|
-
unless pn.file? && pn.extname == '.safariextz'
|
|
70
|
-
raise ArgumentError, "invalid Safari extension path: #{path}"
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
pn
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
24
|
+
attr_accessor :automatic_inspection, :automatic_profiling
|
|
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
|
+
# @see https://developer.apple.com/documentation/webkit/about_webdriver_for_safari
|
|
38
|
+
#
|
|
39
|
+
|
|
40
|
+
def initialize(**opts)
|
|
41
|
+
@automatic_inspection = opts.delete(:automatic_inspection) || false
|
|
42
|
+
@automatic_profiling = opts.delete(:automatic_profiling) || false
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
#
|
|
46
|
+
# @api private
|
|
47
|
+
#
|
|
48
|
+
|
|
49
|
+
def as_json(*)
|
|
50
|
+
opts = {}
|
|
51
|
+
|
|
52
|
+
opts['safari:automaticInspection'] = true if @automatic_inspection
|
|
53
|
+
opts['safari:automaticProfiling'] = true if @automatic_profiling
|
|
54
|
+
|
|
55
|
+
opts
|
|
56
|
+
end
|
|
57
|
+
end # Options
|
|
58
|
+
end # Safari
|
|
59
|
+
end # WebDriver
|
|
60
|
+
end # Selenium
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Licensed to the Software Freedom Conservancy (SFC) under one
|
|
4
|
+
# or more contributor license agreements. See the NOTICE file
|
|
5
|
+
# distributed with this work for additional information
|
|
6
|
+
# regarding copyright ownership. The SFC licenses this file
|
|
7
|
+
# to you under the Apache License, Version 2.0 (the
|
|
8
|
+
# "License"); you may not use this file except in compliance
|
|
9
|
+
# with the License. You may obtain a copy of the License at
|
|
10
|
+
#
|
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
#
|
|
13
|
+
# Unless required by applicable law or agreed to in writing,
|
|
14
|
+
# software distributed under the License is distributed on an
|
|
15
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
# KIND, either express or implied. See the License for the
|
|
17
|
+
# specific language governing permissions and limitations
|
|
18
|
+
# under the License.
|
|
19
|
+
|
|
20
|
+
module Selenium
|
|
21
|
+
module WebDriver
|
|
22
|
+
module Safari
|
|
23
|
+
#
|
|
24
|
+
# @api private
|
|
25
|
+
#
|
|
26
|
+
|
|
27
|
+
class Service < WebDriver::Service
|
|
28
|
+
@default_port = 7050
|
|
29
|
+
@executable = 'safaridriver'
|
|
30
|
+
@missing_text = <<~ERROR
|
|
31
|
+
Unable to find Apple's safaridriver which comes with Safari 10.
|
|
32
|
+
More info at https://webkit.org/blog/6900/webdriver-support-in-safari-10/
|
|
33
|
+
ERROR
|
|
34
|
+
@shutdown_supported = false
|
|
35
|
+
end # Service
|
|
36
|
+
end # Safari
|
|
37
|
+
end # WebDriver
|
|
38
|
+
end # Selenium
|
|
@@ -1,47 +1,65 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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 'selenium/webdriver/safari/bridge'
|
|
21
|
+
require 'selenium/webdriver/safari/driver'
|
|
22
|
+
require 'selenium/webdriver/safari/options'
|
|
3
23
|
|
|
4
24
|
module Selenium
|
|
5
25
|
module WebDriver
|
|
6
26
|
module Safari
|
|
7
|
-
|
|
8
27
|
class << self
|
|
28
|
+
def technology_preview
|
|
29
|
+
"/Applications/Safari\ Technology\ Preview.app/Contents/MacOS/safaridriver"
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def technology_preview!
|
|
33
|
+
self.driver_path = technology_preview
|
|
34
|
+
end
|
|
35
|
+
|
|
9
36
|
def path=(path)
|
|
10
37
|
Platform.assert_executable(path)
|
|
11
38
|
@path = path
|
|
12
39
|
end
|
|
13
40
|
|
|
14
41
|
def path
|
|
15
|
-
@path ||=
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Platform.find_in_program_files("Safari\\Safari.exe")
|
|
19
|
-
when :macosx
|
|
20
|
-
"/Applications/Safari.app/Contents/MacOS/Safari"
|
|
21
|
-
else
|
|
22
|
-
Platform.find_binary("Safari")
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
unless File.file?(path) && File.executable?(path)
|
|
26
|
-
raise Error::WebDriverError, "unable to find the Safari executable, please set Selenium::WebDriver::Safari.path= or add it to your PATH."
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
path
|
|
30
|
-
)
|
|
31
|
-
end
|
|
42
|
+
@path ||= '/Applications/Safari.app/Contents/MacOS/Safari'
|
|
43
|
+
return @path if File.file?(@path) && File.executable?(@path)
|
|
44
|
+
raise Error::WebDriverError, 'Safari is only supported on Mac' unless Platform.os.mac?
|
|
32
45
|
|
|
33
|
-
|
|
34
|
-
@resource_path ||= Pathname.new(File.expand_path("../safari/resources", __FILE__))
|
|
46
|
+
raise Error::WebDriverError, 'Unable to find Safari'
|
|
35
47
|
end
|
|
36
|
-
end
|
|
37
48
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
|
41
54
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
+
end
|
|
61
|
+
end # Safari
|
|
62
|
+
end # WebDriver
|
|
63
|
+
end # Selenium
|
|
47
64
|
|
|
65
|
+
require 'selenium/webdriver/safari/service'
|
|
@@ -1,7 +1,25 @@
|
|
|
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
|
+
|
|
1
20
|
module Selenium
|
|
2
21
|
module WebDriver
|
|
3
22
|
module Support
|
|
4
|
-
|
|
5
23
|
#
|
|
6
24
|
# Subclass and override methods from this class
|
|
7
25
|
# to implement your own event listener.
|
|
@@ -29,25 +47,41 @@ module Selenium
|
|
|
29
47
|
|
|
30
48
|
class AbstractEventListener
|
|
31
49
|
def before_navigate_to(url, driver) end
|
|
50
|
+
|
|
32
51
|
def after_navigate_to(url, driver) end
|
|
52
|
+
|
|
33
53
|
def before_navigate_back(driver) end
|
|
54
|
+
|
|
34
55
|
def after_navigate_back(driver) end
|
|
56
|
+
|
|
35
57
|
def before_navigate_forward(driver) end
|
|
58
|
+
|
|
36
59
|
def after_navigate_forward(driver) end
|
|
60
|
+
|
|
37
61
|
def before_find(by, what, driver) end
|
|
62
|
+
|
|
38
63
|
def after_find(by, what, driver) end
|
|
64
|
+
|
|
39
65
|
def before_click(element, driver) end
|
|
66
|
+
|
|
40
67
|
def after_click(element, driver) end
|
|
68
|
+
|
|
41
69
|
def before_change_value_of(element, driver) end
|
|
70
|
+
|
|
42
71
|
def after_change_value_of(element, driver) end
|
|
72
|
+
|
|
43
73
|
def before_execute_script(script, driver) end
|
|
74
|
+
|
|
44
75
|
def after_execute_script(script, driver) end
|
|
76
|
+
|
|
45
77
|
def before_quit(driver) end
|
|
78
|
+
|
|
46
79
|
def after_quit(driver) end
|
|
80
|
+
|
|
47
81
|
def before_close(driver) end
|
|
48
|
-
def after_close(driver) end
|
|
49
|
-
end
|
|
50
82
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
end
|
|
83
|
+
def after_close(driver) end
|
|
84
|
+
end # AbstractEventListener
|
|
85
|
+
end # Support
|
|
86
|
+
end # WebDriver
|
|
87
|
+
end # Selenium
|
|
@@ -1,17 +1,34 @@
|
|
|
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
|
+
|
|
1
20
|
module Selenium
|
|
2
21
|
module WebDriver
|
|
3
22
|
module Support
|
|
4
|
-
|
|
5
23
|
class BlockEventListener
|
|
6
24
|
def initialize(callback)
|
|
7
25
|
@callback = callback
|
|
8
26
|
end
|
|
9
27
|
|
|
10
|
-
def method_missing(meth, *args,
|
|
28
|
+
def method_missing(meth, *args) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
|
|
11
29
|
@callback.call meth, *args
|
|
12
30
|
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
end
|
|
31
|
+
end # BlockEventListener
|
|
32
|
+
end # Support
|
|
33
|
+
end # WebDriver
|
|
34
|
+
end # Selenium
|
|
@@ -1,87 +1,124 @@
|
|
|
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
|
+
|
|
1
20
|
module Selenium
|
|
2
21
|
module WebDriver
|
|
3
22
|
module Support
|
|
4
23
|
class Color
|
|
5
|
-
RGB_PATTERN
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
24
|
+
RGB_PATTERN = %r{^\s*rgb\(\s*(\d{1,3})\s*,
|
|
25
|
+
\s*(\d{1,3})\s*,
|
|
26
|
+
\s*(\d{1,3})\s*\)\s*$}x.freeze
|
|
27
|
+
RGB_PCT_PATTERN = %r{^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,
|
|
28
|
+
\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,
|
|
29
|
+
\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$}x.freeze
|
|
30
|
+
RGBA_PATTERN = %r{^\s*rgba\(\s*(\d{1,3})\s*,
|
|
31
|
+
\s*(\d{1,3})\s*,
|
|
32
|
+
\s*(\d{1,3})\s*,
|
|
33
|
+
\s*(0|1|0\.\d+)\s*\)\s*$}x.freeze
|
|
34
|
+
RGBA_PCT_PATTERN = %r{^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)
|
|
35
|
+
%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)
|
|
36
|
+
%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)
|
|
37
|
+
%\s*,\s*(0|1|0\.\d+)\s*\)\s*$}x.freeze
|
|
38
|
+
HEX_PATTERN = /#(\h{2})(\h{2})(\h{2})/.freeze
|
|
39
|
+
HEX3_PATTERN = /#(\h)(\h)(\h)/.freeze
|
|
40
|
+
HSL_PATTERN = %r{^\s*hsl\(\s*(\d{1,3})\s*,
|
|
41
|
+
\s*(\d{1,3})%\s*,
|
|
42
|
+
\s*(\d{1,3})%\s*\)\s*$}x.freeze
|
|
43
|
+
HSLA_PATTERN = %r{^\s*hsla\(\s*(\d{1,3})\s*,
|
|
44
|
+
\s*(\d{1,3})%\s*,
|
|
45
|
+
\s*(\d{1,3})%\s*,
|
|
46
|
+
\s*(0|1|0\.\d+)\s*\)\s*$}x.freeze
|
|
13
47
|
|
|
14
48
|
attr_reader :red, :green, :blue, :alpha
|
|
15
49
|
|
|
16
50
|
def self.from_string(str)
|
|
17
51
|
case str
|
|
18
52
|
when RGB_PATTERN
|
|
19
|
-
new
|
|
53
|
+
new Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3)
|
|
20
54
|
when RGB_PCT_PATTERN
|
|
21
|
-
|
|
55
|
+
array = [Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3)]
|
|
56
|
+
new(*array.map { |e| Float(e) / 100 * 255 })
|
|
22
57
|
when RGBA_PATTERN
|
|
23
|
-
new
|
|
58
|
+
new Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3), Regexp.last_match(4)
|
|
24
59
|
when RGBA_PCT_PATTERN
|
|
25
|
-
|
|
60
|
+
array = [Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3)]
|
|
61
|
+
new(*array.map { |e| Float(e) / 100 * 255 } << Regexp.last_match(4))
|
|
26
62
|
when HEX_PATTERN
|
|
27
|
-
|
|
63
|
+
array = [Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3)]
|
|
64
|
+
new(*array.map { |e| e.to_i(16) })
|
|
28
65
|
when HEX3_PATTERN
|
|
29
|
-
|
|
66
|
+
array = [Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3)]
|
|
67
|
+
new(*array.map { |e| (e * 2).to_i(16) })
|
|
30
68
|
when HSL_PATTERN, HSLA_PATTERN
|
|
31
|
-
from_hsl(
|
|
69
|
+
from_hsl(Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3), Regexp.last_match(4))
|
|
32
70
|
else
|
|
33
71
|
raise ArgumentError, "could not convert #{str.inspect} into color"
|
|
34
72
|
end
|
|
35
73
|
end
|
|
36
74
|
|
|
37
|
-
def self.from_hsl(h, s, l, a)
|
|
75
|
+
def self.from_hsl(h, s, l, a) # rubocop:disable Naming/UncommunicativeMethodParamName
|
|
38
76
|
h = Float(h) / 360
|
|
39
77
|
s = Float(s) / 100
|
|
40
78
|
l = Float(l) / 100
|
|
41
79
|
a = Float(a || 1)
|
|
42
80
|
|
|
43
|
-
if s
|
|
81
|
+
if s.zero?
|
|
44
82
|
r = l
|
|
45
83
|
g = r
|
|
46
84
|
b = r
|
|
47
85
|
else
|
|
48
|
-
luminocity2 =
|
|
86
|
+
luminocity2 = l < 0.5 ? l * (1 + s) : l + s - l * s
|
|
49
87
|
luminocity1 = 2 * l - luminocity2
|
|
50
88
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if hue < 1.0 / 6.0
|
|
56
|
-
(lum1 + (lum2 - lum1) * 6.0 * hue)
|
|
57
|
-
elsif hue < 1.0 / 2.0
|
|
58
|
-
lum2
|
|
59
|
-
elsif hue < 2.0 / 3.0
|
|
60
|
-
lum1 + (lum2 - lum1) * ((2.0 / 3.0) - hue) * 6.0
|
|
61
|
-
else
|
|
62
|
-
lum1
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
r = hue_to_rgb.call(luminocity1, luminocity2, h + 1.0 / 3.0)
|
|
67
|
-
g = hue_to_rgb.call(luminocity1, luminocity2, h)
|
|
68
|
-
b = hue_to_rgb.call(luminocity1, luminocity2, h - 1.0 / 3.0)
|
|
89
|
+
r = hue_to_rgb(luminocity1, luminocity2, h + 1.0 / 3.0)
|
|
90
|
+
g = hue_to_rgb(luminocity1, luminocity2, h)
|
|
91
|
+
b = hue_to_rgb(luminocity1, luminocity2, h - 1.0 / 3.0)
|
|
69
92
|
end
|
|
70
93
|
|
|
71
|
-
new r *
|
|
94
|
+
new (r * 255).round, (g * 255).round, (b * 255).round, a
|
|
72
95
|
end
|
|
73
96
|
|
|
97
|
+
def self.hue_to_rgb(lum1, lum2, hue)
|
|
98
|
+
hue += 1 if hue < 0.0
|
|
99
|
+
hue -= 1 if hue > 1.0
|
|
100
|
+
|
|
101
|
+
if hue < 1.0 / 6.0
|
|
102
|
+
(lum1 + (lum2 - lum1) * 6.0 * hue)
|
|
103
|
+
elsif hue < 1.0 / 2.0
|
|
104
|
+
lum2
|
|
105
|
+
elsif hue < 2.0 / 3.0
|
|
106
|
+
lum1 + (lum2 - lum1) * ((2.0 / 3.0) - hue) * 6.0
|
|
107
|
+
else
|
|
108
|
+
lum1
|
|
109
|
+
end
|
|
110
|
+
end
|
|
74
111
|
|
|
75
112
|
def initialize(red, green, blue, alpha = 1)
|
|
76
|
-
@red
|
|
113
|
+
@red = Integer(red)
|
|
77
114
|
@green = Integer(green)
|
|
78
|
-
@blue
|
|
115
|
+
@blue = Integer(blue)
|
|
79
116
|
@alpha = Float(alpha)
|
|
80
117
|
end
|
|
81
118
|
|
|
82
119
|
def ==(other)
|
|
83
120
|
return true if equal?(other)
|
|
84
|
-
return false unless other.
|
|
121
|
+
return false unless other.is_a?(self.class)
|
|
85
122
|
|
|
86
123
|
[red, green, blue, alpha] == [other.red, other.green, other.blue, other.alpha]
|
|
87
124
|
end
|
|
@@ -101,10 +138,9 @@ module Selenium
|
|
|
101
138
|
end
|
|
102
139
|
|
|
103
140
|
def hex
|
|
104
|
-
|
|
141
|
+
format '#%02x%02x%02x', red, green, blue
|
|
105
142
|
end
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
end
|
|
143
|
+
end # Color
|
|
144
|
+
end # Support
|
|
145
|
+
end # WebDriver
|
|
146
|
+
end # Selenium
|