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.
Files changed (139) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +679 -0
  3. data/Gemfile +2 -0
  4. data/LICENSE +1 -1
  5. data/README.md +1 -1
  6. data/lib/selenium-webdriver.rb +2 -2
  7. data/lib/selenium/server.rb +23 -16
  8. data/lib/selenium/webdriver.rb +43 -25
  9. data/lib/selenium/webdriver/atoms.rb +20 -1
  10. data/lib/selenium/webdriver/atoms/findElements.js +122 -0
  11. data/lib/selenium/webdriver/atoms/getAttribute.js +84 -11
  12. data/lib/selenium/webdriver/atoms/isDisplayed.js +100 -0
  13. data/lib/selenium/webdriver/chrome.rb +15 -20
  14. data/lib/selenium/webdriver/chrome/bridge.rb +29 -66
  15. data/lib/selenium/webdriver/{edge/service.rb → chrome/driver.rb} +19 -22
  16. data/lib/selenium/webdriver/chrome/options.rb +221 -0
  17. data/lib/selenium/webdriver/chrome/profile.rb +6 -7
  18. data/lib/selenium/webdriver/chrome/service.rb +20 -20
  19. data/lib/selenium/webdriver/common.rb +19 -11
  20. data/lib/selenium/webdriver/common/action_builder.rb +98 -246
  21. data/lib/selenium/webdriver/common/alert.rb +2 -7
  22. data/lib/selenium/webdriver/common/driver.rb +89 -51
  23. data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +45 -0
  24. data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +50 -0
  25. data/lib/selenium/webdriver/common/driver_extensions/{has_input_devices.rb → has_debugger.rb} +12 -25
  26. data/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb +38 -0
  27. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +3 -5
  28. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +51 -0
  29. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +3 -3
  30. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +51 -0
  31. data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +2 -2
  32. data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +2 -2
  33. data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +2 -2
  34. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +4 -4
  35. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +9 -3
  36. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +3 -5
  37. data/lib/selenium/webdriver/common/element.rb +32 -10
  38. data/lib/selenium/webdriver/common/error.rb +103 -121
  39. data/lib/selenium/webdriver/common/file_reaper.rb +3 -5
  40. data/lib/selenium/webdriver/common/html5/local_storage.rb +2 -2
  41. data/lib/selenium/webdriver/common/html5/session_storage.rb +2 -2
  42. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +3 -2
  43. data/lib/selenium/webdriver/common/interactions/input_device.rb +54 -0
  44. data/lib/selenium/webdriver/common/interactions/interaction.rb +53 -0
  45. data/lib/selenium/webdriver/{phantomjs.rb → common/interactions/interactions.rb} +17 -20
  46. data/lib/selenium/webdriver/common/interactions/key_actions.rb +145 -0
  47. data/lib/selenium/webdriver/common/interactions/key_input.rb +66 -0
  48. data/lib/selenium/webdriver/common/interactions/none_input.rb +36 -0
  49. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +363 -0
  50. data/lib/selenium/webdriver/common/interactions/pointer_input.rb +139 -0
  51. data/lib/selenium/webdriver/common/keys.rb +37 -15
  52. data/lib/selenium/webdriver/common/log_entry.rb +4 -4
  53. data/lib/selenium/webdriver/common/logger.rb +147 -0
  54. data/lib/selenium/webdriver/common/logs.rb +2 -2
  55. data/lib/selenium/webdriver/common/manager.rb +177 -0
  56. data/lib/selenium/webdriver/common/navigation.rb +2 -2
  57. data/lib/selenium/webdriver/common/options.rb +47 -105
  58. data/lib/selenium/webdriver/common/platform.rb +44 -38
  59. data/lib/selenium/webdriver/common/port_prober.rb +8 -19
  60. data/lib/selenium/webdriver/common/profile_helper.rb +13 -5
  61. data/lib/selenium/webdriver/common/proxy.rb +14 -8
  62. data/lib/selenium/webdriver/common/search_context.rb +16 -20
  63. data/lib/selenium/webdriver/common/service.rb +115 -30
  64. data/lib/selenium/webdriver/common/socket_lock.rb +12 -7
  65. data/lib/selenium/webdriver/common/socket_poller.rb +29 -22
  66. data/lib/selenium/webdriver/common/target_locator.rb +6 -6
  67. data/lib/selenium/webdriver/common/timeouts.rb +2 -2
  68. data/lib/selenium/webdriver/common/wait.rb +14 -8
  69. data/lib/selenium/webdriver/common/window.rb +38 -2
  70. data/lib/selenium/webdriver/common/zipper.rb +3 -5
  71. data/lib/selenium/webdriver/edge.rb +33 -20
  72. data/lib/selenium/webdriver/edge_chrome/bridge.rb +30 -0
  73. data/lib/selenium/webdriver/edge_chrome/driver.rb +38 -0
  74. data/lib/selenium/webdriver/{common/driver_extensions/has_touch_screen.rb → edge_chrome/options.rb} +10 -12
  75. data/lib/selenium/webdriver/edge_chrome/profile.rb +33 -0
  76. data/lib/selenium/webdriver/edge_chrome/service.rb +36 -0
  77. data/lib/selenium/webdriver/edge_html/driver.rb +39 -0
  78. data/lib/selenium/webdriver/edge_html/options.rb +91 -0
  79. data/lib/selenium/webdriver/edge_html/service.rb +47 -0
  80. data/lib/selenium/webdriver/firefox.rb +24 -29
  81. data/lib/selenium/webdriver/firefox/bridge.rb +15 -39
  82. data/lib/selenium/webdriver/firefox/{util.rb → driver.rb} +13 -19
  83. data/lib/selenium/webdriver/firefox/extension.rb +28 -8
  84. data/lib/selenium/webdriver/firefox/options.rb +162 -0
  85. data/lib/selenium/webdriver/firefox/profile.rb +23 -82
  86. data/lib/selenium/webdriver/firefox/profiles_ini.rb +5 -5
  87. data/lib/selenium/webdriver/firefox/service.rb +18 -37
  88. data/lib/selenium/webdriver/ie.rb +13 -19
  89. data/lib/selenium/webdriver/ie/driver.rb +40 -0
  90. data/lib/selenium/webdriver/ie/options.rb +118 -0
  91. data/lib/selenium/webdriver/ie/service.rb +20 -20
  92. data/lib/selenium/webdriver/remote.rb +15 -17
  93. data/lib/selenium/webdriver/remote/bridge.rb +281 -300
  94. data/lib/selenium/webdriver/remote/capabilities.rb +102 -83
  95. data/lib/selenium/webdriver/remote/commands.rb +132 -192
  96. data/lib/selenium/webdriver/remote/driver.rb +52 -0
  97. data/lib/selenium/webdriver/remote/http/common.rb +23 -13
  98. data/lib/selenium/webdriver/remote/http/curb.rb +10 -7
  99. data/lib/selenium/webdriver/remote/http/default.rb +52 -32
  100. data/lib/selenium/webdriver/remote/http/persistent.rb +8 -4
  101. data/lib/selenium/webdriver/remote/response.rb +32 -35
  102. data/lib/selenium/webdriver/remote/server_error.rb +2 -2
  103. data/lib/selenium/webdriver/safari.rb +24 -22
  104. data/lib/selenium/webdriver/safari/bridge.rb +21 -21
  105. data/lib/selenium/webdriver/safari/driver.rb +41 -0
  106. data/lib/selenium/webdriver/safari/options.rb +66 -0
  107. data/lib/selenium/webdriver/safari/service.rb +8 -24
  108. data/lib/selenium/webdriver/support.rb +3 -2
  109. data/lib/selenium/webdriver/support/abstract_event_listener.rb +2 -2
  110. data/lib/selenium/webdriver/support/block_event_listener.rb +3 -3
  111. data/lib/selenium/webdriver/support/color.rb +13 -13
  112. data/lib/selenium/webdriver/support/escaper.rb +2 -2
  113. data/lib/selenium/webdriver/support/event_firing_bridge.rb +4 -4
  114. data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
  115. data/lib/selenium/webdriver/support/select.rb +20 -21
  116. data/lib/selenium/webdriver/version.rb +24 -0
  117. data/selenium-webdriver.gemspec +31 -17
  118. metadata +331 -248
  119. data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
  120. data/lib/selenium/webdriver/common/keyboard.rb +0 -69
  121. data/lib/selenium/webdriver/common/mouse.rb +0 -88
  122. data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -81
  123. data/lib/selenium/webdriver/common/touch_screen.rb +0 -121
  124. data/lib/selenium/webdriver/common/w3c_error.rb +0 -191
  125. data/lib/selenium/webdriver/edge/bridge.rb +0 -76
  126. data/lib/selenium/webdriver/edge/legacy_support.rb +0 -117
  127. data/lib/selenium/webdriver/firefox/binary.rb +0 -186
  128. data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
  129. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  130. data/lib/selenium/webdriver/firefox/launcher.rb +0 -114
  131. data/lib/selenium/webdriver/firefox/native/linux/amd64/x_ignore_nofocus.so +0 -0
  132. data/lib/selenium/webdriver/firefox/native/linux/x86/x_ignore_nofocus.so +0 -0
  133. data/lib/selenium/webdriver/firefox/w3c_bridge.rb +0 -79
  134. data/lib/selenium/webdriver/ie/bridge.rb +0 -76
  135. data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -65
  136. data/lib/selenium/webdriver/phantomjs/service.rb +0 -66
  137. data/lib/selenium/webdriver/remote/w3c_bridge.rb +0 -682
  138. data/lib/selenium/webdriver/remote/w3c_capabilities.rb +0 -228
  139. data/lib/selenium/webdriver/remote/w3c_commands.rb +0 -135
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
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
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
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
- MISSING_TEXT = <<-ERROR.tr("\n", '').freeze
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
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 == :macosx
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
- def resource_path
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
- Platform.assert_executable path
50
- @driver_path = path
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
- @driver_path ||= '/usr/bin/safaridriver'
55
- return @driver_path if File.file?(@driver_path) && File.executable?(@driver_path)
56
- raise Error::WebDriverError, MISSING_TEXT
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
- # encoding: utf-8
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
- # @api private
24
- class Bridge < Remote::Bridge
25
- def initialize(opts = {})
26
- opts[:desired_capabilities] ||= Remote::Capabilities.safari
27
- port = opts.delete(:port) || Service::DEFAULT_PORT
28
- service_args = opts.delete(:service_args) || {}
29
-
30
- @service = Service.new(Safari.driver_path, port, *extract_service_args(service_args))
31
- @service.start
32
- opts[:url] = @service.uri
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 quit
38
- super
39
- ensure
40
- @service.stop if @service
36
+ def permissions
37
+ execute(:get_permissions)['permissions']
41
38
  end
42
39
 
43
- private
40
+ def permissions=(permissions)
41
+ execute :set_permissions, {}, {permissions: permissions}
42
+ end
44
43
 
45
- def extract_service_args(args = {})
46
- args.key?(:port) ? ["--port=#{args[:port]}"] : []
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
- # encoding: utf-8
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
- private
31
-
32
- def start_process
33
- server_command = [@executable_path, "--port=#{@port}", *@extra_args]
34
- @process = ChildProcess.build(*server_command)
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
- # encoding: utf-8
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
- # encoding: utf-8
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
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
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
- # encoding: utf-8
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 == 0
81
+ if s.zero?
82
82
  r = l
83
83
  g = r
84
84
  b = r
85
85
  else
86
- luminocity2 = (l < 0.5) ? l * (1 + s) : l + s - l * s
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
- # encoding: utf-8
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
@@ -1,5 +1,5 @@
1
- # encoding: utf-8
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