selenium-webdriver 3.0.0.beta4.0 → 4.0.0.alpha5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGES +679 -0
- data/Gemfile +2 -0
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/lib/selenium-webdriver.rb +2 -2
- data/lib/selenium/server.rb +23 -16
- data/lib/selenium/webdriver.rb +43 -25
- data/lib/selenium/webdriver/atoms.rb +20 -1
- data/lib/selenium/webdriver/atoms/findElements.js +122 -0
- data/lib/selenium/webdriver/atoms/getAttribute.js +84 -11
- data/lib/selenium/webdriver/atoms/isDisplayed.js +100 -0
- data/lib/selenium/webdriver/chrome.rb +15 -20
- data/lib/selenium/webdriver/chrome/bridge.rb +29 -66
- data/lib/selenium/webdriver/{edge/service.rb → chrome/driver.rb} +19 -22
- data/lib/selenium/webdriver/chrome/options.rb +221 -0
- data/lib/selenium/webdriver/chrome/profile.rb +6 -7
- data/lib/selenium/webdriver/chrome/service.rb +20 -20
- data/lib/selenium/webdriver/common.rb +19 -11
- data/lib/selenium/webdriver/common/action_builder.rb +98 -246
- data/lib/selenium/webdriver/common/alert.rb +2 -7
- data/lib/selenium/webdriver/common/driver.rb +89 -51
- 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_input_devices.rb → has_debugger.rb} +12 -25
- data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +38 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +3 -5
- data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +3 -3
- data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +51 -0
- data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +2 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +2 -2
- data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +2 -2
- data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +4 -4
- data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +9 -3
- data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +3 -5
- data/lib/selenium/webdriver/common/element.rb +32 -10
- data/lib/selenium/webdriver/common/error.rb +103 -121
- data/lib/selenium/webdriver/common/file_reaper.rb +3 -5
- data/lib/selenium/webdriver/common/html5/local_storage.rb +2 -2
- data/lib/selenium/webdriver/common/html5/session_storage.rb +2 -2
- data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +3 -2
- 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/{phantomjs.rb → common/interactions/interactions.rb} +17 -20
- 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/keys.rb +37 -15
- data/lib/selenium/webdriver/common/log_entry.rb +4 -4
- data/lib/selenium/webdriver/common/logger.rb +147 -0
- data/lib/selenium/webdriver/common/logs.rb +2 -2
- data/lib/selenium/webdriver/common/manager.rb +177 -0
- data/lib/selenium/webdriver/common/navigation.rb +2 -2
- data/lib/selenium/webdriver/common/options.rb +47 -105
- data/lib/selenium/webdriver/common/platform.rb +44 -38
- data/lib/selenium/webdriver/common/port_prober.rb +8 -19
- data/lib/selenium/webdriver/common/profile_helper.rb +13 -5
- data/lib/selenium/webdriver/common/proxy.rb +14 -8
- data/lib/selenium/webdriver/common/search_context.rb +16 -20
- data/lib/selenium/webdriver/common/service.rb +115 -30
- data/lib/selenium/webdriver/common/socket_lock.rb +12 -7
- data/lib/selenium/webdriver/common/socket_poller.rb +29 -22
- data/lib/selenium/webdriver/common/target_locator.rb +6 -6
- data/lib/selenium/webdriver/common/timeouts.rb +2 -2
- data/lib/selenium/webdriver/common/wait.rb +14 -8
- data/lib/selenium/webdriver/common/window.rb +38 -2
- data/lib/selenium/webdriver/common/zipper.rb +3 -5
- data/lib/selenium/webdriver/edge.rb +33 -20
- data/lib/selenium/webdriver/edge_chrome/bridge.rb +30 -0
- data/lib/selenium/webdriver/edge_chrome/driver.rb +38 -0
- data/lib/selenium/webdriver/{common/driver_extensions/has_touch_screen.rb → edge_chrome/options.rb} +10 -12
- data/lib/selenium/webdriver/edge_chrome/profile.rb +33 -0
- data/lib/selenium/webdriver/edge_chrome/service.rb +36 -0
- data/lib/selenium/webdriver/edge_html/driver.rb +39 -0
- data/lib/selenium/webdriver/edge_html/options.rb +91 -0
- data/lib/selenium/webdriver/edge_html/service.rb +47 -0
- data/lib/selenium/webdriver/firefox.rb +24 -29
- data/lib/selenium/webdriver/firefox/bridge.rb +15 -39
- data/lib/selenium/webdriver/firefox/{util.rb → driver.rb} +13 -19
- data/lib/selenium/webdriver/firefox/extension.rb +28 -8
- data/lib/selenium/webdriver/firefox/options.rb +162 -0
- data/lib/selenium/webdriver/firefox/profile.rb +23 -82
- data/lib/selenium/webdriver/firefox/profiles_ini.rb +5 -5
- data/lib/selenium/webdriver/firefox/service.rb +18 -37
- data/lib/selenium/webdriver/ie.rb +13 -19
- data/lib/selenium/webdriver/ie/driver.rb +40 -0
- data/lib/selenium/webdriver/ie/options.rb +118 -0
- data/lib/selenium/webdriver/ie/service.rb +20 -20
- data/lib/selenium/webdriver/remote.rb +15 -17
- data/lib/selenium/webdriver/remote/bridge.rb +281 -300
- data/lib/selenium/webdriver/remote/capabilities.rb +102 -83
- data/lib/selenium/webdriver/remote/commands.rb +132 -192
- data/lib/selenium/webdriver/remote/driver.rb +52 -0
- data/lib/selenium/webdriver/remote/http/common.rb +23 -13
- data/lib/selenium/webdriver/remote/http/curb.rb +10 -7
- data/lib/selenium/webdriver/remote/http/default.rb +52 -32
- data/lib/selenium/webdriver/remote/http/persistent.rb +8 -4
- data/lib/selenium/webdriver/remote/response.rb +32 -35
- data/lib/selenium/webdriver/remote/server_error.rb +2 -2
- data/lib/selenium/webdriver/safari.rb +24 -22
- data/lib/selenium/webdriver/safari/bridge.rb +21 -21
- data/lib/selenium/webdriver/safari/driver.rb +41 -0
- data/lib/selenium/webdriver/safari/options.rb +66 -0
- data/lib/selenium/webdriver/safari/service.rb +8 -24
- data/lib/selenium/webdriver/support.rb +3 -2
- data/lib/selenium/webdriver/support/abstract_event_listener.rb +2 -2
- data/lib/selenium/webdriver/support/block_event_listener.rb +3 -3
- data/lib/selenium/webdriver/support/color.rb +13 -13
- data/lib/selenium/webdriver/support/escaper.rb +2 -2
- data/lib/selenium/webdriver/support/event_firing_bridge.rb +4 -4
- data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
- data/lib/selenium/webdriver/support/select.rb +20 -21
- data/lib/selenium/webdriver/version.rb +24 -0
- data/selenium-webdriver.gemspec +31 -17
- metadata +331 -248
- data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
- data/lib/selenium/webdriver/common/keyboard.rb +0 -69
- data/lib/selenium/webdriver/common/mouse.rb +0 -88
- data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -81
- data/lib/selenium/webdriver/common/touch_screen.rb +0 -121
- data/lib/selenium/webdriver/common/w3c_error.rb +0 -191
- data/lib/selenium/webdriver/edge/bridge.rb +0 -76
- data/lib/selenium/webdriver/edge/legacy_support.rb +0 -117
- data/lib/selenium/webdriver/firefox/binary.rb +0 -186
- 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 -114
- 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/firefox/w3c_bridge.rb +0 -79
- data/lib/selenium/webdriver/ie/bridge.rb +0 -76
- data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -65
- data/lib/selenium/webdriver/phantomjs/service.rb +0 -66
- data/lib/selenium/webdriver/remote/w3c_bridge.rb +0 -682
- data/lib/selenium/webdriver/remote/w3c_capabilities.rb +0 -228
- data/lib/selenium/webdriver/remote/w3c_commands.rb +0 -135
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
5
5
|
# distributed with this work for additional information
|
@@ -17,18 +17,23 @@
|
|
17
17
|
# specific language governing permissions and limitations
|
18
18
|
# under the License.
|
19
19
|
|
20
|
-
require 'websocket'
|
21
|
-
require 'pathname'
|
22
|
-
|
23
20
|
module Selenium
|
24
21
|
module WebDriver
|
25
22
|
module Safari
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
23
|
+
autoload :Bridge, 'selenium/webdriver/safari/bridge'
|
24
|
+
autoload :Driver, 'selenium/webdriver/safari/driver'
|
25
|
+
autoload :Options, 'selenium/webdriver/safari/options'
|
26
|
+
autoload :Service, 'selenium/webdriver/safari/service'
|
30
27
|
|
31
28
|
class << self
|
29
|
+
def technology_preview
|
30
|
+
"/Applications/Safari\ Technology\ Preview.app/Contents/MacOS/safaridriver"
|
31
|
+
end
|
32
|
+
|
33
|
+
def technology_preview!
|
34
|
+
Service.driver_path = technology_preview
|
35
|
+
end
|
36
|
+
|
32
37
|
def path=(path)
|
33
38
|
Platform.assert_executable(path)
|
34
39
|
@path = path
|
@@ -37,28 +42,25 @@ module Selenium
|
|
37
42
|
def path
|
38
43
|
@path ||= '/Applications/Safari.app/Contents/MacOS/Safari'
|
39
44
|
return @path if File.file?(@path) && File.executable?(@path)
|
40
|
-
raise Error::WebDriverError, 'Safari is only supported on Mac' unless Platform.os
|
41
|
-
raise Error::WebDriverError, 'Unable to find Safari'
|
42
|
-
end
|
45
|
+
raise Error::WebDriverError, 'Safari is only supported on Mac' unless Platform.os.mac?
|
43
46
|
|
44
|
-
|
45
|
-
@resource_path ||= Pathname.new(File.expand_path('../safari/resources', __FILE__))
|
47
|
+
raise Error::WebDriverError, 'Unable to find Safari'
|
46
48
|
end
|
47
49
|
|
48
50
|
def driver_path=(path)
|
49
|
-
|
50
|
-
|
51
|
+
WebDriver.logger.deprecate 'Selenium::WebDriver::Safari#driver_path=',
|
52
|
+
'Selenium::WebDriver::Safari::Service#driver_path=',
|
53
|
+
id: :driver_path
|
54
|
+
Selenium::WebDriver::Safari::Service.driver_path = path
|
51
55
|
end
|
52
56
|
|
53
57
|
def driver_path
|
54
|
-
|
55
|
-
|
56
|
-
|
58
|
+
WebDriver.logger.deprecate 'Selenium::WebDriver::Safari#driver_path',
|
59
|
+
'Selenium::WebDriver::Safari::Service#driver_path',
|
60
|
+
id: :driver_path
|
61
|
+
Selenium::WebDriver::Safari::Service.driver_path
|
57
62
|
end
|
58
63
|
end
|
59
64
|
end # Safari
|
60
65
|
end # WebDriver
|
61
66
|
end # Selenium
|
62
|
-
|
63
|
-
require 'selenium/webdriver/safari/bridge'
|
64
|
-
require 'selenium/webdriver/safari/service'
|
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
5
5
|
# distributed with this work for additional information
|
@@ -20,31 +20,31 @@
|
|
20
20
|
module Selenium
|
21
21
|
module WebDriver
|
22
22
|
module Safari
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
super(opts)
|
23
|
+
module Bridge
|
24
|
+
|
25
|
+
# https://developer.apple.com/library/content/documentation/NetworkingInternetWeb/Conceptual/WebDriverEndpointDoc/Commands/Commands.html
|
26
|
+
COMMANDS = {
|
27
|
+
get_permissions: [:get, 'session/:session_id/apple/permissions'],
|
28
|
+
set_permissions: [:post, 'session/:session_id/apple/permissions'],
|
29
|
+
attach_debugger: [:post, 'session/:session_id/apple/attach_debugger']
|
30
|
+
}.freeze
|
31
|
+
|
32
|
+
def commands(command)
|
33
|
+
COMMANDS[command] || super
|
35
34
|
end
|
36
35
|
|
37
|
-
def
|
38
|
-
|
39
|
-
ensure
|
40
|
-
@service.stop if @service
|
36
|
+
def permissions
|
37
|
+
execute(:get_permissions)['permissions']
|
41
38
|
end
|
42
39
|
|
43
|
-
|
40
|
+
def permissions=(permissions)
|
41
|
+
execute :set_permissions, {}, {permissions: permissions}
|
42
|
+
end
|
44
43
|
|
45
|
-
def
|
46
|
-
|
44
|
+
def attach_debugger
|
45
|
+
execute :attach_debugger, {}, {}
|
47
46
|
end
|
47
|
+
|
48
48
|
end # Bridge
|
49
49
|
end # Safari
|
50
50
|
end # WebDriver
|
@@ -0,0 +1,41 @@
|
|
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::HasWebStorage
|
33
|
+
include DriverExtensions::TakesScreenshot
|
34
|
+
|
35
|
+
def browser
|
36
|
+
:safari
|
37
|
+
end
|
38
|
+
end # Driver
|
39
|
+
end # Safari
|
40
|
+
end # WebDriver
|
41
|
+
end # Selenium
|
@@ -0,0 +1,66 @@
|
|
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
|
+
class Options < WebDriver::Options
|
24
|
+
attr_accessor :options
|
25
|
+
|
26
|
+
# @see https://developer.apple.com/documentation/webkit/about_webdriver_for_safari
|
27
|
+
CAPABILITIES = {automatic_inspection: 'safari:automaticInspection',
|
28
|
+
automatic_profiling: 'safari:automaticProfiling'}.freeze
|
29
|
+
|
30
|
+
CAPABILITIES.each_key do |key|
|
31
|
+
define_method key do
|
32
|
+
@options[key]
|
33
|
+
end
|
34
|
+
|
35
|
+
define_method "#{key}=" do |value|
|
36
|
+
@options[key] = value
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Create a new Options instance for W3C-capable versions of Safari.
|
42
|
+
#
|
43
|
+
# @example
|
44
|
+
# options = Selenium::WebDriver::Safari::Options.new(automatic_inspection: true)
|
45
|
+
# driver = Selenium::WebDriver.for :safari, options: options
|
46
|
+
#
|
47
|
+
# @param [Hash] opts the pre-defined options to create the Safari::Options with
|
48
|
+
# @option opts [Boolean] :automatic_inspection Preloads Web Inspector and JavaScript debugger. Default is false
|
49
|
+
# @option opts [Boolean] :automatic_profiling Preloads Web Inspector and starts a timeline recording. Default is false
|
50
|
+
#
|
51
|
+
|
52
|
+
def initialize(**opts)
|
53
|
+
super
|
54
|
+
end
|
55
|
+
|
56
|
+
#
|
57
|
+
# @api private
|
58
|
+
#
|
59
|
+
|
60
|
+
def as_json(*)
|
61
|
+
generate_as_json(super)
|
62
|
+
end
|
63
|
+
end # Options
|
64
|
+
end # Safari
|
65
|
+
end # WebDriver
|
66
|
+
end # Selenium
|
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
5
5
|
# distributed with this work for additional information
|
@@ -20,30 +20,14 @@
|
|
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
24
|
DEFAULT_PORT = 7050
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
@process.io.inherit! if $DEBUG
|
37
|
-
@process.start
|
38
|
-
end
|
39
|
-
|
40
|
-
def stop_server
|
41
|
-
connect_to_server { |http| http.head('/shutdown') }
|
42
|
-
end
|
43
|
-
|
44
|
-
def cannot_connect_error_text
|
45
|
-
"unable to connect to safaridriver #{@host}:#{@port}"
|
46
|
-
end
|
25
|
+
EXECUTABLE = 'safaridriver'
|
26
|
+
MISSING_TEXT = <<~ERROR
|
27
|
+
Unable to find Apple's safaridriver which comes with Safari 10.
|
28
|
+
More info at https://webkit.org/blog/6900/webdriver-support-in-safari-10/
|
29
|
+
ERROR
|
30
|
+
SHUTDOWN_SUPPORTED = false
|
47
31
|
end # Service
|
48
32
|
end # Safari
|
49
33
|
end # WebDriver
|
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
5
5
|
# distributed with this work for additional information
|
@@ -23,3 +23,4 @@ require 'selenium/webdriver/support/block_event_listener'
|
|
23
23
|
require 'selenium/webdriver/support/escaper'
|
24
24
|
require 'selenium/webdriver/support/select'
|
25
25
|
require 'selenium/webdriver/support/color'
|
26
|
+
require 'selenium/webdriver/support/relative_locator'
|
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
5
5
|
# distributed with this work for additional information
|
@@ -25,7 +25,7 @@ module Selenium
|
|
25
25
|
@callback = callback
|
26
26
|
end
|
27
27
|
|
28
|
-
def method_missing(meth, *args)
|
28
|
+
def method_missing(meth, *args) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
|
29
29
|
@callback.call meth, *args
|
30
30
|
end
|
31
31
|
end # BlockEventListener
|
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
5
5
|
# distributed with this work for additional information
|
@@ -23,27 +23,27 @@ module Selenium
|
|
23
23
|
class Color
|
24
24
|
RGB_PATTERN = %r{^\s*rgb\(\s*(\d{1,3})\s*,
|
25
25
|
\s*(\d{1,3})\s*,
|
26
|
-
\s*(\d{1,3})\s*\)\s*$}x
|
26
|
+
\s*(\d{1,3})\s*\)\s*$}x.freeze
|
27
27
|
RGB_PCT_PATTERN = %r{^\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*$}x
|
29
|
+
\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$}x.freeze
|
30
30
|
RGBA_PATTERN = %r{^\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*$}x
|
33
|
+
\s*(0|1|0\.\d+)\s*\)\s*$}x.freeze
|
34
34
|
RGBA_PCT_PATTERN = %r{^\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*$}x
|
38
|
-
HEX_PATTERN = /#(\h{2})(\h{2})(\h{2})
|
39
|
-
HEX3_PATTERN = /#(\h)(\h)(\h)
|
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
40
|
HSL_PATTERN = %r{^\s*hsl\(\s*(\d{1,3})\s*,
|
41
41
|
\s*(\d{1,3})%\s*,
|
42
|
-
\s*(\d{1,3})%\s*\)\s*$}x
|
42
|
+
\s*(\d{1,3})%\s*\)\s*$}x.freeze
|
43
43
|
HSLA_PATTERN = %r{^\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*$}x
|
46
|
+
\s*(0|1|0\.\d+)\s*\)\s*$}x.freeze
|
47
47
|
|
48
48
|
attr_reader :red, :green, :blue, :alpha
|
49
49
|
|
@@ -72,18 +72,18 @@ module Selenium
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
def self.from_hsl(h, s, l, a)
|
75
|
+
def self.from_hsl(h, s, l, a) # rubocop:disable Naming/UncommunicativeMethodParamName
|
76
76
|
h = Float(h) / 360
|
77
77
|
s = Float(s) / 100
|
78
78
|
l = Float(l) / 100
|
79
79
|
a = Float(a || 1)
|
80
80
|
|
81
|
-
if s
|
81
|
+
if s.zero?
|
82
82
|
r = l
|
83
83
|
g = r
|
84
84
|
b = r
|
85
85
|
else
|
86
|
-
luminocity2 =
|
86
|
+
luminocity2 = l < 0.5 ? l * (1 + s) : l + s - l * s
|
87
87
|
luminocity1 = 2 * l - luminocity2
|
88
88
|
|
89
89
|
r = hue_to_rgb(luminocity1, luminocity2, h + 1.0 / 3.0)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
3
|
# Licensed to the Software Freedom Conservancy (SFC) under one
|
4
4
|
# or more contributor license agreements. See the NOTICE file
|
5
5
|
# distributed with this work for additional information
|
@@ -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,7 +120,7 @@ module Selenium
|
|
120
120
|
returned
|
121
121
|
end
|
122
122
|
|
123
|
-
def method_missing(meth, *args, &blk)
|
123
|
+
def method_missing(meth, *args, &blk) # rubocop:disable Style/MethodMissingSuper, Style/MissingRespondToMissing
|
124
124
|
@delegate.__send__(meth, *args, &blk)
|
125
125
|
end
|
126
126
|
end # EventFiringBridge
|
@@ -0,0 +1,51 @@
|
|
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 Support
|
23
|
+
|
24
|
+
#
|
25
|
+
# @api private
|
26
|
+
#
|
27
|
+
|
28
|
+
class RelativeLocator
|
29
|
+
KEYS = %w[above below left right near distance].freeze
|
30
|
+
|
31
|
+
def initialize(locator)
|
32
|
+
@filters, @root = locator.partition { |how, _| KEYS.include?(how) }.map(&:to_h)
|
33
|
+
end
|
34
|
+
|
35
|
+
def as_json
|
36
|
+
{
|
37
|
+
relative: {
|
38
|
+
root: @root,
|
39
|
+
filters: @filters.map do |kind, filter|
|
40
|
+
{
|
41
|
+
kind: kind,
|
42
|
+
args: [filter]
|
43
|
+
}
|
44
|
+
end
|
45
|
+
}
|
46
|
+
}
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|