selenium-webdriver 2.53.3 → 3.142.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGES +665 -8
  3. data/Gemfile +2 -0
  4. data/LICENSE +1 -1
  5. data/README.md +2 -3
  6. data/lib/selenium/server.rb +76 -73
  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/{phantomjs.rb → atoms.rb} +10 -14
  10. data/lib/selenium/webdriver/chrome/bridge.rb +30 -101
  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 +21 -20
  14. data/lib/selenium/webdriver/chrome/service.rb +26 -93
  15. data/lib/selenium/webdriver/chrome.rb +15 -6
  16. data/lib/selenium/webdriver/common/action_builder.rb +52 -58
  17. data/lib/selenium/webdriver/common/alert.rb +7 -15
  18. data/lib/selenium/webdriver/common/bridge_helper.rb +18 -22
  19. data/lib/selenium/webdriver/common/driver.rb +72 -72
  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_input_devices.rb → has_debugger.rb} +11 -27
  23. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +6 -10
  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 +7 -8
  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 +2 -4
  28. data/lib/selenium/webdriver/common/driver_extensions/has_session_id.rb +2 -4
  29. data/lib/selenium/webdriver/common/driver_extensions/has_touch_screen.rb +3 -5
  30. data/lib/selenium/webdriver/common/driver_extensions/has_web_storage.rb +2 -5
  31. data/lib/selenium/webdriver/common/driver_extensions/rotatable.rb +6 -9
  32. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +9 -7
  33. data/lib/selenium/webdriver/common/driver_extensions/uploads_files.rb +3 -8
  34. data/lib/selenium/webdriver/common/element.rb +59 -39
  35. data/lib/selenium/webdriver/common/error.rb +259 -104
  36. data/lib/selenium/webdriver/common/file_reaper.rb +6 -14
  37. data/lib/selenium/webdriver/common/html5/local_storage.rb +8 -10
  38. data/lib/selenium/webdriver/common/html5/session_storage.rb +8 -10
  39. data/lib/selenium/webdriver/common/html5/shared_web_storage.rb +8 -16
  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/{safari/browser.rb → common/interactions/interactions.rb} +17 -14
  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/{android.rb → common/interactions/none_input.rb} +14 -6
  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 +10 -14
  49. data/lib/selenium/webdriver/common/keys.rb +102 -82
  50. data/lib/selenium/webdriver/common/log_entry.rb +7 -8
  51. data/lib/selenium/webdriver/common/logger.rb +115 -0
  52. data/lib/selenium/webdriver/common/logs.rb +4 -6
  53. data/lib/selenium/webdriver/common/manager.rb +177 -0
  54. data/lib/selenium/webdriver/common/mouse.rb +12 -14
  55. data/lib/selenium/webdriver/common/navigation.rb +4 -6
  56. data/lib/selenium/webdriver/common/options.rb +26 -127
  57. data/lib/selenium/webdriver/common/platform.rb +75 -101
  58. data/lib/selenium/webdriver/common/port_prober.rb +7 -19
  59. data/lib/selenium/webdriver/common/profile_helper.rb +8 -11
  60. data/lib/selenium/webdriver/common/proxy.rb +68 -74
  61. data/lib/selenium/webdriver/common/search_context.rb +28 -37
  62. data/lib/selenium/webdriver/common/service.rb +219 -0
  63. data/lib/selenium/webdriver/common/socket_lock.rb +15 -16
  64. data/lib/selenium/webdriver/common/socket_poller.rb +30 -28
  65. data/lib/selenium/webdriver/common/target_locator.rb +16 -18
  66. data/lib/selenium/webdriver/common/timeouts.rb +6 -8
  67. data/lib/selenium/webdriver/common/touch_action_builder.rb +5 -10
  68. data/lib/selenium/webdriver/common/touch_screen.rb +22 -23
  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 +17 -16
  72. data/lib/selenium/webdriver/common/window.rb +50 -17
  73. data/lib/selenium/webdriver/common/zipper.rb +9 -13
  74. data/lib/selenium/webdriver/common.rb +21 -7
  75. data/lib/selenium/webdriver/edge/bridge.rb +34 -63
  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 +23 -95
  79. data/lib/selenium/webdriver/edge.rb +13 -13
  80. data/lib/selenium/webdriver/firefox/binary.rb +45 -60
  81. data/lib/selenium/webdriver/firefox/driver.rb +50 -0
  82. data/lib/selenium/webdriver/firefox/extension/prefs.json +3 -12
  83. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  84. data/lib/selenium/webdriver/firefox/extension.rb +20 -10
  85. data/lib/selenium/webdriver/firefox/launcher.rb +16 -22
  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 +47 -48
  91. data/lib/selenium/webdriver/firefox/profiles_ini.rb +11 -18
  92. data/lib/selenium/webdriver/firefox/service.rb +24 -95
  93. data/lib/selenium/webdriver/firefox/util.rb +2 -4
  94. data/lib/selenium/webdriver/firefox.rb +27 -12
  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 +12 -10
  99. data/lib/selenium/webdriver/remote/bridge.rb +100 -564
  100. data/lib/selenium/webdriver/remote/capabilities.rb +98 -100
  101. data/lib/selenium/webdriver/remote/driver.rb +51 -0
  102. data/lib/selenium/webdriver/remote/http/common.rb +34 -22
  103. data/lib/selenium/webdriver/remote/http/curb.rb +13 -14
  104. data/lib/selenium/webdriver/remote/http/default.rb +62 -43
  105. data/lib/selenium/webdriver/remote/http/persistent.rb +12 -9
  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 +48 -28
  109. data/lib/selenium/webdriver/remote/server_error.rb +3 -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 +10 -16
  114. data/lib/selenium/webdriver/safari/bridge.rb +17 -101
  115. data/lib/selenium/webdriver/{firefox/w3c_bridge.rb → safari/driver.rb} +27 -25
  116. data/lib/selenium/webdriver/safari/options.rb +29 -31
  117. data/lib/selenium/webdriver/safari/service.rb +38 -0
  118. data/lib/selenium/webdriver/safari.rb +27 -27
  119. data/lib/selenium/webdriver/support/abstract_event_listener.rb +19 -4
  120. data/lib/selenium/webdriver/support/block_event_listener.rb +3 -5
  121. data/lib/selenium/webdriver/support/color.rb +60 -43
  122. data/lib/selenium/webdriver/support/escaper.rb +43 -0
  123. data/lib/selenium/webdriver/support/event_firing_bridge.rb +39 -41
  124. data/lib/selenium/webdriver/support/select.rb +45 -97
  125. data/lib/selenium/webdriver/support.rb +3 -2
  126. data/lib/selenium/webdriver/{iphone.rb → version.rb} +3 -7
  127. data/lib/selenium/webdriver.rb +36 -23
  128. data/lib/selenium-webdriver.rb +2 -2
  129. data/selenium-webdriver.gemspec +42 -29
  130. metadata +331 -262
  131. data/lib/selenium/client/base.rb +0 -151
  132. data/lib/selenium/client/driver.rb +0 -29
  133. data/lib/selenium/client/errors.rb +0 -28
  134. data/lib/selenium/client/extensions.rb +0 -132
  135. data/lib/selenium/client/idiomatic.rb +0 -507
  136. data/lib/selenium/client/javascript_expression_builder.rb +0 -135
  137. data/lib/selenium/client/javascript_frameworks/jquery.rb +0 -32
  138. data/lib/selenium/client/javascript_frameworks/prototype.rb +0 -32
  139. data/lib/selenium/client/legacy_driver.rb +0 -1722
  140. data/lib/selenium/client/protocol.rb +0 -123
  141. data/lib/selenium/client/selenium_helper.rb +0 -49
  142. data/lib/selenium/client.rb +0 -57
  143. data/lib/selenium/rake/server_task.rb +0 -176
  144. data/lib/selenium/webdriver/android/bridge.rb +0 -68
  145. data/lib/selenium/webdriver/common/core_ext/base64.rb +0 -28
  146. data/lib/selenium/webdriver/common/core_ext/dir.rb +0 -61
  147. data/lib/selenium/webdriver/common/html5/location.rb +0 -19
  148. data/lib/selenium/webdriver/common/w3c_error.rb +0 -194
  149. data/lib/selenium/webdriver/edge/legacy_support.rb +0 -117
  150. data/lib/selenium/webdriver/firefox/bridge.rb +0 -89
  151. data/lib/selenium/webdriver/ie/bridge.rb +0 -88
  152. data/lib/selenium/webdriver/ie/server.rb +0 -133
  153. data/lib/selenium/webdriver/iphone/bridge.rb +0 -64
  154. data/lib/selenium/webdriver/phantomjs/bridge.rb +0 -78
  155. data/lib/selenium/webdriver/phantomjs/service.rb +0 -130
  156. data/lib/selenium/webdriver/remote/commands.rb +0 -211
  157. data/lib/selenium/webdriver/remote/w3c_bridge.rb +0 -668
  158. data/lib/selenium/webdriver/remote/w3c_capabilities.rb +0 -236
  159. data/lib/selenium/webdriver/remote/w3c_commands.rb +0 -132
  160. data/lib/selenium/webdriver/safari/resources/client.js +0 -7255
  161. data/lib/selenium/webdriver/safari/server.rb +0 -187
  162. data/lib/selenium-client.rb +0 -21
@@ -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,104 +20,33 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Firefox
23
-
24
23
  #
25
24
  # @api private
26
25
  #
27
- class Service
28
- START_TIMEOUT = 20
29
- SOCKET_LOCK_TIMEOUT = 45
30
- STOP_TIMEOUT = 5
31
- DEFAULT_PORT = 4444
32
- MISSING_TEXT = "Unable to find geckodriver. Please download the executable from https://github.com/mozilla/geckodriver/releases"
33
-
34
- def self.executable_path
35
- @executable_path ||= (
36
- path = Platform.find_binary("geckodriver*") || Platform.find_binary("wires*")
37
- path or raise Error::WebDriverError, MISSING_TEXT
38
- Platform.assert_executable path
39
-
40
- path
41
- )
42
- end
43
-
44
- def self.executable_path=(path)
45
- Platform.assert_executable path
46
- @executable_path = path
47
- end
48
-
49
- def self.default_service(*extra_args)
50
- new executable_path, DEFAULT_PORT, *extra_args
51
- end
52
-
53
- def initialize(executable_path, port, *extra_args)
54
- @executable_path = executable_path
55
- @host = Platform.localhost
56
- @port = Integer(port)
57
-
58
- raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1
59
-
60
- @extra_args = extra_args
61
- end
62
-
63
- def start
64
- Platform.exit_hook { stop } # make sure we don't leave the server running
65
-
66
- socket_lock.locked do
67
- find_free_port
68
- start_process
69
- connect_until_stable
70
- end
71
- end
72
26
 
73
- def stop
74
- return if @process.nil? || @process.exited?
75
-
76
- Net::HTTP.start(@host, @port) do |http|
77
- http.open_timeout = STOP_TIMEOUT / 2
78
- http.read_timeout = STOP_TIMEOUT / 2
79
-
80
- http.head("/shutdown")
81
- end
82
- ensure
83
- stop_process
84
- end
85
-
86
- def uri
87
- URI.parse "http://#{@host}:#{@port}"
88
- end
89
-
90
- def find_free_port
91
- @port = PortProber.above @port
92
- end
93
-
94
- def start_process
95
- server_command = [@executable_path, "--binary=#{Firefox::Binary.path}", "--webdriver-port=#{@port}", *@extra_args]
96
- @process = ChildProcess.build(*server_command)
97
-
98
- @process.io.inherit! if $DEBUG || Platform.os == :windows
99
- @process.start
27
+ class Service < WebDriver::Service
28
+ @default_port = 4444
29
+ @executable = 'geckodriver'
30
+ @missing_text = <<~ERROR
31
+ Unable to find Mozilla geckodriver. Please download the server from
32
+ https://github.com/mozilla/geckodriver/releases and place it somewhere on your PATH.
33
+ More info at https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver.
34
+ ERROR
35
+ @shutdown_supported = false
36
+
37
+ private
38
+
39
+ # Note: This processing is deprecated
40
+ def extract_service_args(driver_opts)
41
+ driver_args = super
42
+ driver_opts = driver_opts.dup
43
+ driver_args << "--binary=#{driver_opts[:binary]}" if driver_opts.key?(:binary)
44
+ driver_args << "--log=#{driver_opts[:log]}" if driver_opts.key?(:log)
45
+ driver_args << "--marionette-port=#{driver_opts[:marionette_port]}" if driver_opts.key?(:marionette_port)
46
+ driver_args << "--host=#{driver_opts[:host]}" if driver_opts.key?(:host)
47
+ driver_args
100
48
  end
101
-
102
- def stop_process
103
- @process.poll_for_exit STOP_TIMEOUT
104
- rescue ChildProcess::TimeoutError
105
- @process.stop STOP_TIMEOUT
106
- end
107
-
108
- def connect_until_stable
109
- @socket_poller = SocketPoller.new @host, @port, START_TIMEOUT
110
-
111
- unless @socket_poller.connected?
112
- raise Error::WebDriverError, "unable to connect to Mozilla geckodriver #{@host}:#{@port}"
113
- end
114
- end
115
-
116
- def socket_lock
117
- @socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT)
118
- end
119
-
120
49
  end # Service
121
50
  end # Firefox
122
51
  end # WebDriver
123
- end # Service
52
+ 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,7 +20,6 @@
20
20
  module Selenium
21
21
  module WebDriver
22
22
  module Firefox
23
-
24
23
  # @api private
25
24
  module Util
26
25
  module_function
@@ -41,7 +40,6 @@ module Selenium
41
40
  def stringified?(str)
42
41
  str =~ /^".*"$/
43
42
  end
44
-
45
43
  end # Util
46
44
  end # Firefox
47
45
  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
@@ -21,31 +21,46 @@ require 'timeout'
21
21
  require 'socket'
22
22
  require 'rexml/document'
23
23
 
24
+ require 'selenium/webdriver/firefox/driver'
25
+
24
26
  require 'selenium/webdriver/firefox/util'
25
27
  require 'selenium/webdriver/firefox/extension'
26
28
  require 'selenium/webdriver/firefox/binary'
27
29
  require 'selenium/webdriver/firefox/profiles_ini'
28
30
  require 'selenium/webdriver/firefox/profile'
29
31
  require 'selenium/webdriver/firefox/launcher'
30
- require 'selenium/webdriver/firefox/bridge'
31
- require 'selenium/webdriver/firefox/w3c_bridge'
32
- require 'selenium/webdriver/firefox/binary'
33
- require 'selenium/webdriver/firefox/service'
32
+ require 'selenium/webdriver/firefox/legacy/driver'
33
+
34
+ require 'selenium/webdriver/firefox/marionette/bridge'
35
+ require 'selenium/webdriver/firefox/marionette/driver'
36
+ require 'selenium/webdriver/firefox/options'
34
37
 
35
38
  module Selenium
36
39
  module WebDriver
37
40
  module Firefox
38
-
39
- DEFAULT_PORT = 7055
40
- DEFAULT_ENABLE_NATIVE_EVENTS = Platform.os == :windows
41
- DEFAULT_SECURE_SSL = false
41
+ DEFAULT_PORT = 7055
42
+ DEFAULT_ENABLE_NATIVE_EVENTS = Platform.os == :windows
43
+ DEFAULT_SECURE_SSL = false
42
44
  DEFAULT_ASSUME_UNTRUSTED_ISSUER = true
43
- DEFAULT_LOAD_NO_FOCUS_LIB = false
45
+ DEFAULT_LOAD_NO_FOCUS_LIB = false
46
+
47
+ def self.driver_path=(path)
48
+ WebDriver.logger.deprecate 'Selenium::WebDriver::Firefox#driver_path=',
49
+ 'Selenium::WebDriver::Firefox::Service#driver_path='
50
+ Selenium::WebDriver::Firefox::Service.driver_path = path
51
+ end
52
+
53
+ def self.driver_path
54
+ WebDriver.logger.deprecate 'Selenium::WebDriver::Firefox#driver_path',
55
+ 'Selenium::WebDriver::Firefox::Service#driver_path'
56
+ Selenium::WebDriver::Firefox::Service.driver_path
57
+ end
44
58
 
45
59
  def self.path=(path)
46
60
  Binary.path = path
47
61
  end
48
-
49
62
  end # Firefox
50
63
  end # WebDriver
51
64
  end # Selenium
65
+
66
+ require 'selenium/webdriver/firefox/service'
@@ -0,0 +1,85 @@
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 IE
23
+
24
+ #
25
+ # Driver implementation for Internet Explorer supporting
26
+ # both OSS and W3C dialects of JSON wire protocol.
27
+ # @api private
28
+ #
29
+
30
+ class Driver < WebDriver::Driver
31
+ include DriverExtensions::HasWebStorage
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
+ super(@bridge, listener: listener)
42
+ end
43
+
44
+ def browser
45
+ :internet_explorer
46
+ end
47
+
48
+ def quit
49
+ super
50
+ ensure
51
+ @service&.stop
52
+ end
53
+
54
+ private
55
+
56
+ def create_capabilities(opts)
57
+ caps = opts.delete(:desired_capabilities) { Remote::Capabilities.internet_explorer }
58
+ options = opts.delete(:options) { Options.new }
59
+
60
+ if opts.delete(:introduce_flakiness_by_ignoring_security_domains)
61
+ WebDriver.logger.deprecate ':introduce_flakiness_by_ignoring_security_domains',
62
+ 'Selenium::WebDriver::IE::Options#ignore_protected_mode_settings='
63
+ options.ignore_protected_mode_settings = true
64
+ end
65
+
66
+ native_events = opts.delete(:native_events)
67
+ unless native_events.nil?
68
+ WebDriver.logger.deprecate ':native_events', 'Selenium::WebDriver::IE::Options#native_events='
69
+ options.native_events = native_events
70
+ end
71
+
72
+ # Backward compatibility with older IEDriverServer versions
73
+ caps[:ignore_protected_mode_settings] = options.ignore_protected_mode_settings
74
+ caps[:native_events] = options.native_events
75
+
76
+ options = options.as_json
77
+ caps.merge!(options) unless options.empty?
78
+
79
+ caps
80
+ end
81
+
82
+ end # Driver
83
+ end # IE
84
+ end # WebDriver
85
+ end # Selenium
@@ -0,0 +1,138 @@
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 IE
23
+ class Options < WebDriver::Common::Options
24
+ KEY = 'se:ieOptions'
25
+ SCROLL_TOP = 0
26
+ SCROLL_BOTTOM = 1
27
+ CAPABILITIES = {
28
+ browser_attach_timeout: 'browserAttachTimeout',
29
+ element_scroll_behavior: 'elementScrollBehavior',
30
+ full_page_screenshot: 'ie.enableFullPageScreenshot',
31
+ ensure_clean_session: 'ie.ensureCleanSession',
32
+ file_upload_dialog_timeout: 'ie.fileUploadDialogTimeout',
33
+ force_create_process_api: 'ie.forceCreateProcessApi',
34
+ force_shell_windows_api: 'ie.forceShellWindowsApi',
35
+ ignore_protected_mode_settings: 'ignoreProtectedModeSettings',
36
+ ignore_zoom_level: 'ignoreZoomSetting',
37
+ initial_browser_url: 'initialBrowserUrl',
38
+ native_events: 'nativeEvents',
39
+ persistent_hover: 'enablePersistentHover',
40
+ require_window_focus: 'requireWindowFocus',
41
+ use_per_process_proxy: 'ie.usePerProcessProxy',
42
+ validate_cookie_document_type: 'ie.validateCookieDocumentType'
43
+ }.freeze
44
+
45
+ CAPABILITIES.each_key do |key|
46
+ define_method key do
47
+ @options[key]
48
+ end
49
+
50
+ define_method "#{key}=" do |value|
51
+ @options[key] = value
52
+ end
53
+ end
54
+
55
+ attr_reader :args, :options
56
+
57
+ #
58
+ # Create a new Options instance
59
+ #
60
+ # @example
61
+ # options = Selenium::WebDriver::IE::Options.new(args: ['--host=127.0.0.1'])
62
+ # driver = Selenium::WebDriver.for(:ie, options: options)
63
+ #
64
+ # @example
65
+ # options = Selenium::WebDriver::IE::Options.new
66
+ # options.element_scroll_behavior = Selenium::WebDriver::IE::Options::SCROLL_BOTTOM
67
+ # driver = Selenium::WebDriver.for(:ie, options: options)
68
+ #
69
+ # @param [Hash] opts the pre-defined options
70
+ # @option opts [Array<String>] args
71
+ # @option opts [Integer] browser_attach_timeout
72
+ # @option opts [Integer] element_scroll_behavior Either SCROLL_TOP or SCROLL_BOTTOM
73
+ # @option opts [Boolean] full_page_screenshot
74
+ # @option opts [Boolean] ensure_clean_session
75
+ # @option opts [Integer] file_upload_dialog_timeout
76
+ # @option opts [Boolean] force_create_process_api
77
+ # @option opts [Boolean] force_shell_windows_api
78
+ # @option opts [Boolean] ignore_protected_mode_settings
79
+ # @option opts [Boolean] ignore_zoom_level
80
+ # @option opts [String] initial_browser_url
81
+ # @option opts [Boolean] native_events
82
+ # @option opts [Boolean] persistent_hover
83
+ # @option opts [Boolean] require_window_focus
84
+ # @option opts [Boolean] use_per_process_proxy
85
+ # @option opts [Boolean] validate_cookie_document_type
86
+ #
87
+
88
+ def initialize(**opts)
89
+ @args = Set.new(opts.delete(:args) || [])
90
+ @options = opts
91
+ @options[:native_events] = true if @options[:native_events].nil?
92
+ end
93
+
94
+ #
95
+ # Add a command-line argument to use when starting Internet Explorer.
96
+ #
97
+ # @param [String] arg The command-line argument to add
98
+ #
99
+
100
+ def add_argument(arg)
101
+ @args << arg
102
+ end
103
+
104
+ #
105
+ # Add a new option not yet handled by these bindings.
106
+ #
107
+ # @example
108
+ # options = Selenium::WebDriver::IE::Options.new
109
+ # options.add_option(:foo, 'bar')
110
+ #
111
+ # @param [String, Symbol] name Name of the option
112
+ # @param [Boolean, String, Integer] value Value of the option
113
+ #
114
+
115
+ def add_option(name, value)
116
+ @options[name] = value
117
+ end
118
+
119
+ #
120
+ # @api private
121
+ #
122
+
123
+ def as_json(*)
124
+ opts = {}
125
+
126
+ CAPABILITIES.each do |capability_alias, capability_name|
127
+ capability_value = @options.delete(capability_alias)
128
+ opts[capability_name] = capability_value unless capability_value.nil?
129
+ end
130
+ opts['ie.browserCommandLineSwitches'] = @args.to_a.join(' ') if @args.any?
131
+ opts.merge!(@options)
132
+
133
+ {KEY => generate_as_json(opts)}
134
+ end
135
+ end # Options
136
+ end # IE
137
+ end # WebDriver
138
+ end # Selenium
@@ -0,0 +1,54 @@
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 IE
23
+ #
24
+ # @api private
25
+ #
26
+
27
+ class Service < WebDriver::Service
28
+ @default_port = 5555
29
+ @executable = 'IEDriverServer'
30
+ @missing_text = <<~ERROR
31
+ Unable to find IEDriverServer. Please download the server from
32
+ http://selenium-release.storage.googleapis.com/index.html and place it somewhere on your PATH.
33
+ More info at https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver.
34
+ ERROR
35
+ @shutdown_supported = true
36
+
37
+ private
38
+
39
+ # Note: This processing is deprecated
40
+ def extract_service_args(driver_opts)
41
+ driver_args = super
42
+ driver_opts = driver_opts.dup
43
+ driver_args << "--log-level=#{driver_opts.delete(:log_level).to_s.upcase}" if driver_opts.key?(:log_level)
44
+ driver_args << "--log-file=#{driver_opts.delete(:log_file)}" if driver_opts.key?(:log_file)
45
+ driver_args << "--implementation=#{driver_opts.delete(:implementation).to_s.upcase}" if driver_opts.key?(:implementation)
46
+ driver_args << "--host=#{driver_opts.delete(:host)}" if driver_opts.key?(:host)
47
+ driver_args << "--extract_path=#{driver_opts.delete(:extract_path)}" if driver_opts.key?(:extract_path)
48
+ driver_args << "--silent" if driver_opts[:silent] == true
49
+ driver_args
50
+ end
51
+ end # Server
52
+ end # IE
53
+ end # WebDriver
54
+ 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
@@ -17,23 +17,25 @@
17
17
  # specific language governing permissions and limitations
18
18
  # under the License.
19
19
 
20
+ require 'selenium/webdriver/ie/driver'
21
+ require 'selenium/webdriver/ie/options'
22
+
20
23
  module Selenium
21
24
  module WebDriver
22
-
23
- # @api private
24
25
  module IE
25
26
  def self.driver_path=(path)
26
- Platform.assert_executable path
27
- @driver_path = path
27
+ WebDriver.logger.deprecate 'Selenium::WebDriver::IE#driver_path=',
28
+ 'Selenium::WebDriver::IE::Service#driver_path='
29
+ Selenium::WebDriver::IE::Service.driver_path = path
28
30
  end
29
31
 
30
32
  def self.driver_path
31
- @driver_path ||= nil
33
+ WebDriver.logger.deprecate 'Selenium::WebDriver::IE#driver_path',
34
+ 'Selenium::WebDriver::IE::Service#driver_path'
35
+ Selenium::WebDriver::IE::Service.driver_path
32
36
  end
33
-
34
37
  end # IE
35
38
  end # WebDriver
36
39
  end # Selenium
37
40
 
38
- require 'selenium/webdriver/ie/server'
39
- require 'selenium/webdriver/ie/bridge'
41
+ require 'selenium/webdriver/ie/service'