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.
Files changed (172) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +795 -3
  3. data/Gemfile +2 -0
  4. data/{COPYING → LICENSE} +1 -3
  5. data/README.md +13 -9
  6. data/lib/selenium/server.rb +93 -71
  7. data/lib/selenium/webdriver/atoms/getAttribute.js +7 -0
  8. data/lib/selenium/webdriver/atoms/isDisplayed.js +102 -0
  9. data/lib/selenium/webdriver/atoms.rb +37 -0
  10. data/lib/selenium/webdriver/chrome/bridge.rb +47 -99
  11. data/lib/selenium/webdriver/chrome/driver.rb +127 -0
  12. data/lib/selenium/webdriver/chrome/options.rb +190 -0
  13. data/lib/selenium/webdriver/chrome/profile.rb +40 -20
  14. data/lib/selenium/webdriver/chrome/service.rb +46 -62
  15. data/lib/selenium/webdriver/chrome.rb +34 -6
  16. data/lib/selenium/webdriver/common/action_builder.rb +69 -56
  17. data/lib/selenium/webdriver/common/alert.rb +25 -8
  18. data/lib/selenium/webdriver/common/bridge_helper.rb +35 -20
  19. data/lib/selenium/webdriver/common/driver.rb +90 -63
  20. data/lib/selenium/webdriver/common/driver_extensions/downloads_files.rb +45 -0
  21. data/lib/selenium/webdriver/common/driver_extensions/has_addons.rb +50 -0
  22. data/lib/selenium/webdriver/common/driver_extensions/has_debugger.rb +42 -0
  23. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +26 -11
  24. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +51 -0
  25. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +58 -0
  26. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +51 -0
  27. data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +23 -6
  28. data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +19 -2
  29. data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +24 -7
  30. data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +19 -3
  31. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +23 -7
  32. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +26 -5
  33. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +20 -6
  34. data/lib/selenium/webdriver/common/element.rb +79 -37
  35. data/lib/selenium/webdriver/common/error.rb +282 -106
  36. data/lib/selenium/webdriver/common/file_reaper.rb +23 -12
  37. data/lib/selenium/webdriver/common/html5/local_storage.rb +29 -12
  38. data/lib/selenium/webdriver/common/html5/session_storage.rb +29 -12
  39. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +29 -18
  40. data/lib/selenium/webdriver/common/interactions/input_device.rb +54 -0
  41. data/lib/selenium/webdriver/common/interactions/interaction.rb +53 -0
  42. data/lib/selenium/webdriver/common/interactions/interactions.rb +43 -0
  43. data/lib/selenium/webdriver/common/interactions/key_actions.rb +145 -0
  44. data/lib/selenium/webdriver/common/interactions/key_input.rb +66 -0
  45. data/lib/selenium/webdriver/common/interactions/none_input.rb +36 -0
  46. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +363 -0
  47. data/lib/selenium/webdriver/common/interactions/pointer_input.rb +139 -0
  48. data/lib/selenium/webdriver/common/keyboard.rb +27 -12
  49. data/lib/selenium/webdriver/common/keys.rb +118 -81
  50. data/lib/selenium/webdriver/common/log_entry.rb +27 -8
  51. data/lib/selenium/webdriver/common/logger.rb +115 -0
  52. data/lib/selenium/webdriver/common/logs.rb +24 -7
  53. data/lib/selenium/webdriver/common/manager.rb +177 -0
  54. data/lib/selenium/webdriver/common/mouse.rb +29 -12
  55. data/lib/selenium/webdriver/common/navigation.rb +21 -4
  56. data/lib/selenium/webdriver/common/options.rb +43 -126
  57. data/lib/selenium/webdriver/common/platform.rb +101 -97
  58. data/lib/selenium/webdriver/common/port_prober.rb +24 -17
  59. data/lib/selenium/webdriver/common/profile_helper.rb +27 -11
  60. data/lib/selenium/webdriver/common/proxy.rb +86 -73
  61. data/lib/selenium/webdriver/common/search_context.rb +49 -33
  62. data/lib/selenium/webdriver/common/service.rb +219 -0
  63. data/lib/selenium/webdriver/common/socket_lock.rb +82 -0
  64. data/lib/selenium/webdriver/common/socket_poller.rb +47 -26
  65. data/lib/selenium/webdriver/common/target_locator.rb +35 -14
  66. data/lib/selenium/webdriver/common/timeouts.rb +23 -6
  67. data/lib/selenium/webdriver/common/touch_action_builder.rb +25 -11
  68. data/lib/selenium/webdriver/common/touch_screen.rb +42 -24
  69. data/lib/selenium/webdriver/common/w3c_action_builder.rb +212 -0
  70. data/lib/selenium/webdriver/common/w3c_manager.rb +45 -0
  71. data/lib/selenium/webdriver/common/wait.rb +34 -14
  72. data/lib/selenium/webdriver/common/window.rb +75 -16
  73. data/lib/selenium/webdriver/common/zipper.rb +26 -11
  74. data/lib/selenium/webdriver/common.rb +40 -7
  75. data/lib/selenium/webdriver/edge/bridge.rb +76 -0
  76. data/lib/selenium/webdriver/edge/driver.rb +66 -0
  77. data/lib/selenium/webdriver/edge/options.rb +80 -0
  78. data/lib/selenium/webdriver/edge/service.rb +52 -0
  79. data/lib/selenium/webdriver/edge.rb +44 -0
  80. data/lib/selenium/webdriver/firefox/binary.rb +70 -48
  81. data/lib/selenium/webdriver/firefox/driver.rb +50 -0
  82. data/lib/selenium/webdriver/firefox/extension/prefs.json +14 -13
  83. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  84. data/lib/selenium/webdriver/firefox/extension.rb +50 -19
  85. data/lib/selenium/webdriver/firefox/launcher.rb +33 -28
  86. data/lib/selenium/webdriver/firefox/legacy/driver.rb +83 -0
  87. data/lib/selenium/webdriver/firefox/marionette/bridge.rb +49 -0
  88. data/lib/selenium/webdriver/firefox/marionette/driver.rb +90 -0
  89. data/lib/selenium/webdriver/firefox/options.rb +162 -0
  90. data/lib/selenium/webdriver/firefox/profile.rb +66 -48
  91. data/lib/selenium/webdriver/firefox/profiles_ini.rb +28 -16
  92. data/lib/selenium/webdriver/firefox/service.rb +52 -0
  93. data/lib/selenium/webdriver/firefox/util.rb +19 -2
  94. data/lib/selenium/webdriver/firefox.rb +46 -10
  95. data/lib/selenium/webdriver/ie/driver.rb +85 -0
  96. data/lib/selenium/webdriver/ie/options.rb +138 -0
  97. data/lib/selenium/webdriver/ie/service.rb +54 -0
  98. data/lib/selenium/webdriver/ie.rb +32 -10
  99. data/lib/selenium/webdriver/remote/bridge.rb +117 -572
  100. data/lib/selenium/webdriver/remote/capabilities.rb +116 -99
  101. data/lib/selenium/webdriver/remote/driver.rb +51 -0
  102. data/lib/selenium/webdriver/remote/http/common.rb +54 -23
  103. data/lib/selenium/webdriver/remote/http/curb.rb +30 -12
  104. data/lib/selenium/webdriver/remote/http/default.rb +85 -42
  105. data/lib/selenium/webdriver/remote/http/persistent.rb +29 -7
  106. data/lib/selenium/webdriver/remote/oss/bridge.rb +594 -0
  107. data/lib/selenium/webdriver/remote/oss/commands.rb +223 -0
  108. data/lib/selenium/webdriver/remote/response.rb +68 -30
  109. data/lib/selenium/webdriver/remote/server_error.rb +22 -5
  110. data/lib/selenium/webdriver/remote/w3c/bridge.rb +605 -0
  111. data/lib/selenium/webdriver/remote/w3c/capabilities.rb +310 -0
  112. data/lib/selenium/webdriver/remote/w3c/commands.rb +157 -0
  113. data/lib/selenium/webdriver/remote.rb +27 -13
  114. data/lib/selenium/webdriver/safari/bridge.rb +38 -107
  115. data/lib/selenium/webdriver/safari/driver.rb +68 -0
  116. data/lib/selenium/webdriver/safari/options.rb +56 -75
  117. data/lib/selenium/webdriver/safari/service.rb +38 -0
  118. data/lib/selenium/webdriver/safari.rb +49 -31
  119. data/lib/selenium/webdriver/support/abstract_event_listener.rb +40 -6
  120. data/lib/selenium/webdriver/support/block_event_listener.rb +24 -7
  121. data/lib/selenium/webdriver/support/color.rb +82 -46
  122. data/lib/selenium/webdriver/support/escaper.rb +43 -0
  123. data/lib/selenium/webdriver/support/event_firing_bridge.rb +56 -39
  124. data/lib/selenium/webdriver/support/select.rb +66 -89
  125. data/lib/selenium/webdriver/support.rb +20 -0
  126. data/lib/selenium/webdriver/version.rb +24 -0
  127. data/lib/selenium/webdriver.rb +55 -25
  128. data/lib/selenium-webdriver.rb +19 -0
  129. data/selenium-webdriver.gemspec +42 -29
  130. metadata +331 -260
  131. data/Gemfile.lock +0 -48
  132. data/lib/selenium/client/base.rb +0 -132
  133. data/lib/selenium/client/driver.rb +0 -10
  134. data/lib/selenium/client/errors.rb +0 -9
  135. data/lib/selenium/client/extensions.rb +0 -118
  136. data/lib/selenium/client/idiomatic.rb +0 -488
  137. data/lib/selenium/client/javascript_expression_builder.rb +0 -116
  138. data/lib/selenium/client/javascript_frameworks/jquery.rb +0 -13
  139. data/lib/selenium/client/javascript_frameworks/prototype.rb +0 -13
  140. data/lib/selenium/client/legacy_driver.rb +0 -1720
  141. data/lib/selenium/client/protocol.rb +0 -104
  142. data/lib/selenium/client/selenium_helper.rb +0 -34
  143. data/lib/selenium/client.rb +0 -38
  144. data/lib/selenium/rake/server_task.rb +0 -157
  145. data/lib/selenium/webdriver/android/bridge.rb +0 -49
  146. data/lib/selenium/webdriver/android.rb +0 -9
  147. data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -9
  148. data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -42
  149. data/lib/selenium/webdriver/common/core_ext/string.rb +0 -5
  150. data/lib/selenium/webdriver/common/driver_extensions/has_browser_connection.rb +0 -17
  151. data/lib/selenium/webdriver/common/driver_extensions/has_input_devices.rb +0 -39
  152. data/lib/selenium/webdriver/common/html5/location.rb +0 -0
  153. data/lib/selenium/webdriver/common/json_helper.rb +0 -34
  154. data/lib/selenium/webdriver/firefox/bridge.rb +0 -70
  155. data/lib/selenium/webdriver/firefox/socket_lock.rb +0 -61
  156. data/lib/selenium/webdriver/ie/bridge.rb +0 -69
  157. data/lib/selenium/webdriver/ie/server.rb +0 -90
  158. data/lib/selenium/webdriver/iphone/bridge.rb +0 -45
  159. data/lib/selenium/webdriver/iphone.rb +0 -9
  160. data/lib/selenium/webdriver/opera/bridge.rb +0 -112
  161. data/lib/selenium/webdriver/opera/service.rb +0 -49
  162. data/lib/selenium/webdriver/opera.rb +0 -24
  163. data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -59
  164. data/lib/selenium/webdriver/phantomjs/service.rb +0 -90
  165. data/lib/selenium/webdriver/phantomjs.rb +0 -22
  166. data/lib/selenium/webdriver/remote/commands.rb +0 -192
  167. data/lib/selenium/webdriver/safari/browser.rb +0 -20
  168. data/lib/selenium/webdriver/safari/extensions.rb +0 -170
  169. data/lib/selenium/webdriver/safari/resources/SafariDriver.safariextz +0 -0
  170. data/lib/selenium/webdriver/safari/resources/client.js +0 -6903
  171. data/lib/selenium/webdriver/safari/server.rb +0 -145
  172. 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 :port, :data_dir, :skip_extension_installation
6
- attr_reader :extensions
7
-
8
- def initialize(opts = {})
9
- @extensions = []
10
- extract_options(opts)
11
- end
12
-
13
- def add_extension(ext)
14
- @extensions << verify_safari_extension(ext)
15
- end
16
-
17
- def clean_session?
18
- !!@clean_session
19
- end
20
-
21
- def skip_extension_installation?
22
- !!@skip_extension_installation
23
- end
24
-
25
- def to_capabilities
26
- caps = Remote::Capabilities.safari
27
- caps.merge!('safari.options' => as_json)
28
-
29
- caps
30
- end
31
-
32
- def as_json
33
- {
34
- 'port' => port,
35
- 'dataDir' => data_dir,
36
- 'cleanSession' => clean_session?,
37
- 'extensions' => extensions_as_json,
38
- 'skipExtensionInstallation' => skip_extension_installation?
39
- }
40
- end
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
- require 'websocket'
2
- require 'pathname'
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
- path = case Platform.os
17
- when :windows
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
- def resource_path
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
- end
39
- end
40
- end
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
- require 'selenium/webdriver/safari/browser'
43
- require 'selenium/webdriver/safari/server'
44
- require 'selenium/webdriver/safari/extensions'
45
- require 'selenium/webdriver/safari/options'
46
- require 'selenium/webdriver/safari/bridge'
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
- end
52
- end
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, &blk)
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
- end
16
- end
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 = /^\s*rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)\s*$/
6
- RGB_PCT_PATTERN = /^\s*rgb\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*\)\s*$/
7
- RGBA_PATTERN = /^\s*rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0\.\d+)\s*\)\s*$/
8
- RGBA_PCT_PATTERN = /^\s*rgba\(\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(\d{1,3}|\d{1,2}\.\d+)%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/
9
- HEX_PATTERN = /#([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})([A-Fa-f0-9]{2})/ # \p{XDigit} or \h only works on Ruby 1.9
10
- HEX3_PATTERN = /#([A-Fa-f0-9])([A-Fa-f0-9])([A-Fa-f0-9])/ # \p{XDigit} or \h only works on Ruby 1.9
11
- HSL_PATTERN = /^\s*hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)\s*$/
12
- HSLA_PATTERN = /^\s*hsla\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*,\s*(0|1|0\.\d+)\s*\)\s*$/
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 $1, $2, $3
53
+ new Regexp.last_match(1), Regexp.last_match(2), Regexp.last_match(3)
20
54
  when RGB_PCT_PATTERN
21
- new(*[$1, $2, $3].map { |e| Float(e) / 100 * 255 })
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 $1, $2, $3, $4
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
- new(*[$1, $2, $3].map { |e| Float(e) / 100 * 255 } << $4)
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
- new(*[$1, $2, $3].map { |e| e.to_i(16) })
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
- new(*[$1, $2, $3].map { |e| (e * 2).to_i(16) })
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($1, $2, $3, $4)
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 == 0
81
+ if s.zero?
44
82
  r = l
45
83
  g = r
46
84
  b = r
47
85
  else
48
- luminocity2 = (l < 0.5) ? l * (1 + s) : l + s - l * s
86
+ luminocity2 = l < 0.5 ? l * (1 + s) : l + s - l * s
49
87
  luminocity1 = 2 * l - luminocity2
50
88
 
51
- hue_to_rgb = lambda do |lum1, lum2, hue|
52
- hue += 1 if hue < 0.0
53
- hue -= 1 if hue > 1.0
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 * 256, g * 256, b * 256, a
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 = Integer(red)
113
+ @red = Integer(red)
77
114
  @green = Integer(green)
78
- @blue = Integer(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.kind_of?(self.class)
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
- "#%02x%02x%02x" % [red, green, blue]
141
+ format '#%02x%02x%02x', red, green, blue
105
142
  end
106
-
107
- end
108
- end
109
- end
110
- end
143
+ end # Color
144
+ end # Support
145
+ end # WebDriver
146
+ end # Selenium