selenium-webdriver 3.142.1 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGES +406 -4
  3. data/Gemfile +3 -1
  4. data/LICENSE +1 -1
  5. data/NOTICE +2 -0
  6. data/README.md +4 -5
  7. data/lib/selenium/server.rb +69 -63
  8. data/lib/selenium/webdriver/atoms/findElements.js +122 -0
  9. data/lib/selenium/webdriver/atoms/getAttribute.js +100 -7
  10. data/lib/selenium/webdriver/atoms/isDisplayed.js +76 -78
  11. data/lib/selenium/webdriver/atoms/mutationListener.js +55 -0
  12. data/lib/selenium/webdriver/chrome/driver.rb +26 -70
  13. data/lib/selenium/webdriver/chrome/features.rb +106 -0
  14. data/lib/selenium/webdriver/chrome/options.rb +128 -53
  15. data/lib/selenium/webdriver/chrome/profile.rb +8 -5
  16. data/lib/selenium/webdriver/chrome/service.rb +8 -15
  17. data/lib/selenium/webdriver/chrome.rb +10 -9
  18. data/lib/selenium/webdriver/common/action_builder.rb +97 -249
  19. data/lib/selenium/webdriver/common/driver.rb +112 -23
  20. data/lib/selenium/webdriver/common/driver_extensions/full_page_screenshot.rb +43 -0
  21. data/lib/selenium/webdriver/common/driver_extensions/has_apple_permissions.rb +51 -0
  22. data/lib/selenium/webdriver/common/driver_extensions/has_authentication.rb +89 -0
  23. data/lib/selenium/webdriver/common/driver_extensions/has_casting.rb +77 -0
  24. data/lib/selenium/webdriver/common/driver_extensions/{has_touch_screen.rb → has_cdp.rb} +10 -8
  25. data/lib/selenium/webdriver/common/driver_extensions/has_context.rb +45 -0
  26. data/lib/selenium/webdriver/{firefox/util.rb → common/driver_extensions/has_devtools.rb} +16 -19
  27. data/lib/selenium/webdriver/common/driver_extensions/has_launching.rb +38 -0
  28. data/lib/selenium/webdriver/common/driver_extensions/has_location.rb +5 -8
  29. data/lib/selenium/webdriver/common/driver_extensions/has_log_events.rb +144 -0
  30. data/lib/selenium/webdriver/common/driver_extensions/has_logs.rb +30 -0
  31. data/lib/selenium/webdriver/common/driver_extensions/has_network_conditions.rb +17 -0
  32. data/lib/selenium/webdriver/common/driver_extensions/has_network_connection.rb +6 -27
  33. data/lib/selenium/webdriver/common/driver_extensions/has_network_interception.rb +136 -0
  34. data/lib/selenium/webdriver/common/driver_extensions/has_permissions.rb +11 -11
  35. data/lib/selenium/webdriver/common/driver_extensions/has_pinned_scripts.rb +77 -0
  36. data/lib/selenium/webdriver/common/driver_extensions/has_remote_status.rb +1 -0
  37. data/lib/selenium/webdriver/common/driver_extensions/{rotatable.rb → prints_page.rb} +18 -20
  38. data/lib/selenium/webdriver/common/element.rb +82 -22
  39. data/lib/selenium/webdriver/common/error.rb +32 -196
  40. data/lib/selenium/webdriver/common/interactions/interaction.rb +4 -1
  41. data/lib/selenium/webdriver/common/interactions/key_actions.rb +5 -5
  42. data/lib/selenium/webdriver/common/interactions/pointer_actions.rb +13 -13
  43. data/lib/selenium/webdriver/common/log_entry.rb +2 -2
  44. data/lib/selenium/webdriver/common/logger.rb +50 -15
  45. data/lib/selenium/webdriver/common/manager.rb +15 -15
  46. data/lib/selenium/webdriver/common/options.rb +184 -0
  47. data/lib/selenium/webdriver/common/platform.rb +6 -1
  48. data/lib/selenium/webdriver/common/port_prober.rb +4 -6
  49. data/lib/selenium/webdriver/common/profile_helper.rb +11 -9
  50. data/lib/selenium/webdriver/common/proxy.rb +6 -3
  51. data/lib/selenium/webdriver/common/search_context.rb +7 -3
  52. data/lib/selenium/webdriver/common/service.rb +27 -122
  53. data/lib/selenium/webdriver/common/service_manager.rb +151 -0
  54. data/lib/selenium/webdriver/common/shadow_root.rb +87 -0
  55. data/lib/selenium/webdriver/common/socket_lock.rb +2 -2
  56. data/lib/selenium/webdriver/common/socket_poller.rb +2 -2
  57. data/lib/selenium/webdriver/common/takes_screenshot.rb +66 -0
  58. data/lib/selenium/webdriver/common/target_locator.rb +32 -4
  59. data/lib/selenium/webdriver/common/timeouts.rb +31 -4
  60. data/lib/selenium/webdriver/common/wait.rb +1 -1
  61. data/lib/selenium/webdriver/common/window.rb +0 -4
  62. data/lib/selenium/webdriver/common/zipper.rb +3 -9
  63. data/lib/selenium/webdriver/common.rb +24 -17
  64. data/lib/selenium/webdriver/devtools/console_event.rb +38 -0
  65. data/lib/selenium/webdriver/devtools/exception_event.rb +36 -0
  66. data/lib/selenium/webdriver/devtools/mutation_event.rb +37 -0
  67. data/lib/selenium/webdriver/devtools/pinned_script.rb +59 -0
  68. data/lib/selenium/webdriver/devtools/request.rb +67 -0
  69. data/lib/selenium/webdriver/devtools/response.rb +66 -0
  70. data/lib/selenium/webdriver/devtools.rb +193 -0
  71. data/lib/selenium/webdriver/edge/driver.rb +7 -29
  72. data/lib/selenium/webdriver/{chrome/bridge.rb → edge/features.rb} +16 -22
  73. data/lib/selenium/webdriver/edge/options.rb +11 -48
  74. data/lib/selenium/webdriver/{common/w3c_manager.rb → edge/profile.rb} +7 -19
  75. data/lib/selenium/webdriver/edge/service.rb +10 -26
  76. data/lib/selenium/webdriver/edge.rb +11 -14
  77. data/lib/selenium/webdriver/firefox/driver.rb +31 -19
  78. data/lib/selenium/webdriver/firefox/extension.rb +8 -0
  79. data/lib/selenium/webdriver/firefox/{bridge.rb → features.rb} +23 -4
  80. data/lib/selenium/webdriver/firefox/options.rb +71 -50
  81. data/lib/selenium/webdriver/firefox/profile.rb +21 -71
  82. data/lib/selenium/webdriver/firefox/service.rb +5 -9
  83. data/lib/selenium/webdriver/firefox.rb +22 -20
  84. data/lib/selenium/webdriver/ie/driver.rb +1 -47
  85. data/lib/selenium/webdriver/ie/options.rb +15 -46
  86. data/lib/selenium/webdriver/ie/service.rb +13 -15
  87. data/lib/selenium/webdriver/ie.rb +8 -7
  88. data/lib/selenium/webdriver/remote/bridge.rb +561 -86
  89. data/lib/selenium/webdriver/remote/capabilities.rb +159 -123
  90. data/lib/selenium/webdriver/remote/commands.rb +7 -0
  91. data/lib/selenium/webdriver/remote/driver.rb +22 -12
  92. data/lib/selenium/webdriver/remote/http/common.rb +0 -5
  93. data/lib/selenium/webdriver/remote/http/default.rb +17 -20
  94. data/lib/selenium/webdriver/remote/http/persistent.rb +11 -6
  95. data/lib/selenium/webdriver/remote/response.rb +16 -47
  96. data/lib/selenium/webdriver/remote.rb +15 -12
  97. data/lib/selenium/webdriver/safari/driver.rb +3 -31
  98. data/lib/selenium/webdriver/safari/{bridge.rb → features.rb} +6 -6
  99. data/lib/selenium/webdriver/safari/options.rb +10 -29
  100. data/lib/selenium/webdriver/safari/service.rb +4 -8
  101. data/lib/selenium/webdriver/safari.rb +17 -9
  102. data/lib/selenium/webdriver/support/block_event_listener.rb +1 -1
  103. data/lib/selenium/webdriver/support/cdp/domain.rb.erb +63 -0
  104. data/lib/selenium/webdriver/support/cdp_client_generator.rb +108 -0
  105. data/lib/selenium/webdriver/support/color.rb +2 -2
  106. data/lib/selenium/webdriver/support/event_firing_bridge.rb +4 -4
  107. data/lib/selenium/webdriver/support/guards/guard.rb +89 -0
  108. data/lib/selenium/webdriver/{firefox/marionette/bridge.rb → support/guards/guard_condition.rb} +22 -19
  109. data/lib/selenium/webdriver/support/guards.rb +95 -0
  110. data/lib/selenium/webdriver/support/relative_locator.rb +51 -0
  111. data/lib/selenium/webdriver/support/select.rb +3 -3
  112. data/lib/selenium/webdriver/support.rb +1 -0
  113. data/lib/selenium/webdriver/version.rb +1 -1
  114. data/lib/selenium/webdriver.rb +13 -13
  115. data/selenium-webdriver.gemspec +29 -13
  116. metadata +125 -73
  117. data/lib/selenium/webdriver/common/bridge_helper.rb +0 -82
  118. data/lib/selenium/webdriver/common/driver_extensions/takes_screenshot.rb +0 -64
  119. data/lib/selenium/webdriver/common/keyboard.rb +0 -70
  120. data/lib/selenium/webdriver/common/mouse.rb +0 -89
  121. data/lib/selenium/webdriver/common/touch_action_builder.rb +0 -78
  122. data/lib/selenium/webdriver/common/touch_screen.rb +0 -123
  123. data/lib/selenium/webdriver/common/w3c_action_builder.rb +0 -212
  124. data/lib/selenium/webdriver/edge/bridge.rb +0 -76
  125. data/lib/selenium/webdriver/firefox/binary.rb +0 -187
  126. data/lib/selenium/webdriver/firefox/extension/prefs.json +0 -69
  127. data/lib/selenium/webdriver/firefox/extension/webdriver.xpi +0 -0
  128. data/lib/selenium/webdriver/firefox/launcher.rb +0 -111
  129. data/lib/selenium/webdriver/firefox/legacy/driver.rb +0 -83
  130. data/lib/selenium/webdriver/firefox/marionette/driver.rb +0 -90
  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/remote/oss/bridge.rb +0 -594
  134. data/lib/selenium/webdriver/remote/oss/commands.rb +0 -223
  135. data/lib/selenium/webdriver/remote/w3c/bridge.rb +0 -605
  136. data/lib/selenium/webdriver/remote/w3c/capabilities.rb +0 -310
  137. data/lib/selenium/webdriver/remote/w3c/commands.rb +0 -157
@@ -1,187 +0,0 @@
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 Firefox
23
- # @api private
24
- class Binary
25
- NO_FOCUS_LIBRARY_NAME = 'x_ignore_nofocus.so'
26
- NO_FOCUS_LIBRARIES = [
27
- ["#{WebDriver.root}/selenium/webdriver/firefox/native/linux/amd64/#{NO_FOCUS_LIBRARY_NAME}",
28
- "amd64/#{NO_FOCUS_LIBRARY_NAME}"],
29
- ["#{WebDriver.root}/selenium/webdriver/firefox/native/linux/x86/#{NO_FOCUS_LIBRARY_NAME}",
30
- "x86/#{NO_FOCUS_LIBRARY_NAME}"]
31
- ].freeze
32
-
33
- WAIT_TIMEOUT = 90
34
- QUIT_TIMEOUT = 5
35
-
36
- def start_with(profile, profile_path, *args)
37
- if Platform.cygwin?
38
- profile_path = Platform.cygwin_path(profile_path, windows: true)
39
- elsif Platform.windows?
40
- profile_path = Platform.windows_path(profile_path)
41
- end
42
-
43
- ENV['XRE_CONSOLE_LOG'] = profile.log_file if profile.log_file
44
- ENV['XRE_PROFILE_PATH'] = profile_path
45
- ENV['MOZ_NO_REMOTE'] = '1' # able to launch multiple instances
46
- ENV['MOZ_CRASHREPORTER_DISABLE'] = '1' # disable breakpad
47
- ENV['NO_EM_RESTART'] = '1' # prevent the binary from detaching from the console
48
-
49
- modify_link_library_path profile_path if Platform.linux? && (profile.native_events? || profile.load_no_focus_lib?)
50
-
51
- execute(*args)
52
- end
53
-
54
- def quit
55
- return unless @process
56
-
57
- @process.poll_for_exit QUIT_TIMEOUT
58
- rescue ChildProcess::TimeoutError
59
- # ok, force quit
60
- @process.stop QUIT_TIMEOUT
61
- end
62
-
63
- def wait
64
- return unless @process
65
-
66
- begin
67
- @process.poll_for_exit(WAIT_TIMEOUT)
68
- rescue ChildProcess::TimeoutError => e
69
- @process.stop
70
- raise e
71
- end
72
- end
73
-
74
- private
75
-
76
- def execute(*extra_args)
77
- args = [self.class.path, '-no-remote'] + extra_args
78
- @process = ChildProcess.build(*args)
79
- WebDriver.logger.debug("Executing Process #{args}")
80
-
81
- @process.io.stdout = @process.io.stderr = WebDriver.logger.io if WebDriver.logger.debug?
82
- @process.start
83
- end
84
-
85
- def modify_link_library_path(profile_path)
86
- paths = []
87
-
88
- NO_FOCUS_LIBRARIES.each do |from, to|
89
- dest = File.join(profile_path, to)
90
- FileUtils.mkdir_p File.dirname(dest)
91
- FileUtils.cp from, dest
92
-
93
- paths << File.expand_path(File.dirname(dest))
94
- end
95
-
96
- paths += ENV['LD_LIBRARY_PATH'].to_s.split(File::PATH_SEPARATOR)
97
-
98
- ENV['LD_LIBRARY_PATH'] = paths.uniq.join(File::PATH_SEPARATOR)
99
- ENV['LD_PRELOAD'] = NO_FOCUS_LIBRARY_NAME
100
- end
101
-
102
- class << self
103
- #
104
- # @api private
105
- #
106
- # @see Firefox.path=
107
- #
108
-
109
- def path=(path)
110
- Platform.assert_executable(path)
111
- @path = path
112
- end
113
-
114
- def reset_path!
115
- @path = nil
116
- end
117
-
118
- def path
119
- @path ||= case Platform.os
120
- when :macosx
121
- macosx_path
122
- when :windows
123
- windows_path
124
- when :linux, :unix
125
- Platform.find_binary('firefox3', 'firefox2', 'firefox') || '/usr/bin/firefox'
126
- else
127
- raise Error::WebDriverError, "unknown platform: #{Platform.os}"
128
- end
129
-
130
- @path = Platform.cygwin_path(@path, windows: true) if Platform.cygwin?
131
-
132
- unless File.file?(@path.to_s)
133
- error = "Could not find Firefox binary (os=#{Platform.os}). "
134
- error << "Make sure Firefox is installed or set the path manually with #{self}.path="
135
- raise Error::WebDriverError, error
136
- end
137
-
138
- @path
139
- end
140
-
141
- def version
142
- @version = case Platform.os
143
- when :macosx
144
- `#{path} -v`.strip[/[^\s]*$/][/^\d+/].to_i
145
- when :windows
146
- `\"#{path}\" -v | more`.strip[/[^\s]*$/][/^\d+/].to_i
147
- when :linux
148
- `#{path} -v`.strip[/[^\s]*$/][/^\d+/].to_i
149
- else
150
- 0
151
- end
152
- end
153
-
154
- private
155
-
156
- def windows_path
157
- windows_registry_path ||
158
- Platform.find_in_program_files('\\Mozilla Firefox\\firefox.exe') ||
159
- Platform.find_binary('firefox')
160
- end
161
-
162
- def macosx_path
163
- path = '/Applications/Firefox.app/Contents/MacOS/firefox-bin'
164
- path = File.expand_path('~/Applications/Firefox.app/Contents/MacOS/firefox-bin') unless File.exist?(path)
165
- path = Platform.find_binary('firefox-bin') unless File.exist?(path)
166
-
167
- path
168
- end
169
-
170
- def windows_registry_path
171
- require 'win32/registry'
172
-
173
- lm = Win32::Registry::HKEY_LOCAL_MACHINE
174
- lm.open('SOFTWARE\\Mozilla\\Mozilla Firefox') do |reg|
175
- main = lm.open("SOFTWARE\\Mozilla\\Mozilla Firefox\\#{reg.keys[0]}\\Main")
176
- entry = main.find { |key, _type, _data| key =~ /pathtoexe/i }
177
- return entry.last if entry
178
- end
179
- rescue LoadError
180
- # older JRuby or IronRuby does not have win32/registry
181
- rescue Win32::Registry::Error
182
- end
183
- end # class << self
184
- end # Binary
185
- end # Firefox
186
- end # WebDriver
187
- end # Selenium
@@ -1,69 +0,0 @@
1
- {
2
- "frozen": {
3
- "app.update.auto": false,
4
- "app.update.enabled": false,
5
- "browser.displayedE10SNotice": 4,
6
- "browser.download.manager.showWhenStarting": false,
7
- "browser.EULA.override": true,
8
- "browser.EULA.3.accepted": true,
9
- "browser.link.open_external": 2,
10
- "browser.link.open_newwindow": 2,
11
- "browser.offline": false,
12
- "browser.reader.detectedFirstArticle": true,
13
- "browser.safebrowsing.enabled": false,
14
- "browser.safebrowsing.malware.enabled": false,
15
- "browser.search.update": false,
16
- "browser.selfsupport.url" : "",
17
- "browser.sessionstore.resume_from_crash": false,
18
- "browser.shell.checkDefaultBrowser": false,
19
- "browser.tabs.warnOnClose": false,
20
- "browser.tabs.warnOnOpen": false,
21
- "datareporting.healthreport.service.enabled": false,
22
- "datareporting.healthreport.uploadEnabled": false,
23
- "datareporting.healthreport.service.firstRun": false,
24
- "datareporting.healthreport.logging.consoleEnabled": false,
25
- "datareporting.policy.dataSubmissionEnabled": false,
26
- "datareporting.policy.dataSubmissionPolicyAccepted": false,
27
- "devtools.errorconsole.enabled": true,
28
- "dom.disable_open_during_load": false,
29
- "extensions.autoDisableScopes": 10,
30
- "extensions.blocklist.enabled": false,
31
- "extensions.checkCompatibility.nightly": false,
32
- "extensions.update.enabled": false,
33
- "extensions.update.notifyUser": false,
34
- "javascript.enabled": true,
35
- "network.manage-offline-status": false,
36
- "network.http.phishy-userpass-length": 255,
37
- "offline-apps.allow_by_default": true,
38
- "prompts.tab_modal.enabled": false,
39
- "security.fileuri.origin_policy": 3,
40
- "security.fileuri.strict_origin_policy": false,
41
- "signon.rememberSignons": false,
42
- "toolkit.networkmanager.disable": true,
43
- "toolkit.telemetry.prompted": 2,
44
- "toolkit.telemetry.enabled": false,
45
- "toolkit.telemetry.rejected": true,
46
- "xpinstall.signatures.required": false,
47
- "xpinstall.whitelist.required": false
48
- },
49
- "mutable": {
50
- "browser.dom.window.dump.enabled": true,
51
- "browser.laterrun.enabled": false,
52
- "browser.newtab.url": "about:blank",
53
- "browser.newtabpage.enabled": false,
54
- "browser.startup.page": 0,
55
- "browser.startup.homepage": "about:blank",
56
- "browser.startup.homepage_override.mstone": "ignore",
57
- "browser.usedOnWindows10.introURL": "about:blank",
58
- "dom.max_chrome_script_run_time": 30,
59
- "dom.max_script_run_time": 30,
60
- "dom.report_all_js_exceptions": true,
61
- "javascript.options.showInConsole": true,
62
- "network.captive-portal-service.enabled": false,
63
- "security.csp.enable": false,
64
- "startup.homepage_welcome_url": "about:blank",
65
- "startup.homepage_welcome_url.additional": "about:blank",
66
- "webdriver_accept_untrusted_certs": true,
67
- "webdriver_assume_untrusted_issuer": true
68
- }
69
- }
@@ -1,111 +0,0 @@
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 Firefox
23
- # @api private
24
- class Launcher
25
- SOCKET_LOCK_TIMEOUT = 45
26
- STABLE_CONNECTION_TIMEOUT = 60
27
-
28
- def initialize(binary, port, profile = nil)
29
- @binary = binary
30
- @port = Integer(port)
31
-
32
- raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1
33
-
34
- if profile.is_a? Profile
35
- @profile = profile
36
- else
37
- @profile_name = profile
38
- @profile = nil
39
- end
40
-
41
- @host = '127.0.0.1'
42
- end
43
-
44
- def url
45
- "http://#{@host}:#{@port}/hub"
46
- end
47
-
48
- def launch
49
- socket_lock.locked do
50
- find_free_port
51
- create_profile
52
- start
53
- connect_until_stable
54
- end
55
-
56
- self
57
- end
58
-
59
- def quit
60
- @binary.quit
61
- FileReaper.reap(@profile_dir) if @profile_dir
62
- end
63
-
64
- def find_free_port
65
- @port = PortProber.above @port
66
- end
67
-
68
- def create_profile
69
- fetch_profile unless @profile
70
-
71
- @profile.add_webdriver_extension
72
- @profile.port = @port
73
-
74
- @profile_dir = @profile.layout_on_disk
75
- FileReaper << @profile_dir
76
- end
77
-
78
- def start
79
- assert_profile
80
- @binary.start_with @profile, @profile_dir, '-foreground'
81
- end
82
-
83
- def connect_until_stable
84
- poller = SocketPoller.new(@host, @port, STABLE_CONNECTION_TIMEOUT)
85
-
86
- return if poller.connected?
87
-
88
- @binary.quit
89
- error = "unable to obtain stable firefox connection in #{STABLE_CONNECTION_TIMEOUT} seconds (#{@host}:#{@port})"
90
- raise Error::WebDriverError, error
91
- end
92
-
93
- def fetch_profile
94
- @profile = if @profile_name
95
- Profile.from_name @profile_name
96
- else
97
- Profile.new
98
- end
99
- end
100
-
101
- def assert_profile
102
- raise Error::WebDriverError, 'must create_profile first' unless @profile && @profile_dir
103
- end
104
-
105
- def socket_lock
106
- @socket_lock ||= SocketLock.new(@port - 1, SOCKET_LOCK_TIMEOUT)
107
- end
108
- end # Launcher
109
- end # Firefox
110
- end # WebDriver
111
- end # Selenium
@@ -1,83 +0,0 @@
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 Firefox
23
- module Legacy
24
-
25
- #
26
- # Driver implementation for Firefox using legacy extension.
27
- # @api private
28
- #
29
-
30
- class Driver < WebDriver::Driver
31
- include DriverExtensions::TakesScreenshot
32
-
33
- def initialize(opts = {}) # rubocop:disable Metrics/AbcSize
34
- WebDriver.logger.deprecate 'Selenium support for legacy Firefox', 'Firefox via marionette'
35
-
36
- opts[:desired_capabilities] ||= Remote::Capabilities.firefox_legacy
37
-
38
- if opts.key? :proxy
39
- WebDriver.logger.deprecate ':proxy', "Selenium::WebDriver::Remote::Capabilities.firefox(proxy: #{opts[:proxy]})"
40
- opts[:desired_capabilities].proxy = opts.delete(:proxy)
41
- end
42
-
43
- unless opts.key?(:url)
44
- port = opts.delete(:port) || DEFAULT_PORT
45
- profile = opts.delete(:profile)
46
-
47
- Binary.path = opts[:desired_capabilities][:firefox_binary] if opts[:desired_capabilities][:firefox_binary]
48
- @launcher = Launcher.new Binary.new, port, profile
49
- @launcher.launch
50
- opts[:url] = @launcher.url
51
- end
52
-
53
- listener = opts.delete(:listener)
54
- WebDriver.logger.info 'Skipping handshake as we know it is OSS.'
55
- desired_capabilities = opts.delete(:desired_capabilities)
56
- bridge = Remote::Bridge.new(opts)
57
- capabilities = bridge.create_session(desired_capabilities)
58
- @bridge = Remote::OSS::Bridge.new(capabilities, bridge.session_id, opts)
59
-
60
- begin
61
- super(@bridge, listener: listener)
62
- rescue
63
- @launcher&.quit
64
- raise
65
- end
66
- end
67
-
68
- def browser
69
- :firefox
70
- end
71
-
72
- def quit
73
- super
74
- nil
75
- ensure
76
- @launcher.quit
77
- end
78
-
79
- end # Driver
80
- end # Legacy
81
- end # Firefox
82
- end # WebDriver
83
- end # Selenium
@@ -1,90 +0,0 @@
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 Firefox
23
- module Marionette
24
-
25
- #
26
- # Driver implementation for Firefox using GeckoDriver.
27
- # @api private
28
- #
29
-
30
- class Driver < WebDriver::Driver
31
- include DriverExtensions::HasAddons
32
- include DriverExtensions::HasWebStorage
33
- include DriverExtensions::TakesScreenshot
34
-
35
- def initialize(opts = {})
36
- opts[:desired_capabilities] = create_capabilities(opts)
37
-
38
- opts[:url] ||= service_url(opts)
39
-
40
- listener = opts.delete(:listener)
41
- WebDriver.logger.info 'Skipping handshake as we know it is W3C.'
42
- desired_capabilities = opts.delete(:desired_capabilities)
43
- bridge = Remote::Bridge.new(opts)
44
- capabilities = bridge.create_session(desired_capabilities)
45
- @bridge = Remote::W3C::Bridge.new(capabilities, bridge.session_id, opts)
46
- @bridge.extend Marionette::Bridge
47
-
48
- super(@bridge, listener: listener)
49
- end
50
-
51
- def browser
52
- :firefox
53
- end
54
-
55
- def quit
56
- super
57
- ensure
58
- @service&.stop
59
- end
60
-
61
- private
62
-
63
- def create_capabilities(opts)
64
- caps = opts.delete(:desired_capabilities) { Remote::Capabilities.firefox }
65
- options = opts.delete(:options) { Options.new }
66
-
67
- firefox_options = opts.delete(:firefox_options)
68
- if firefox_options
69
- WebDriver.logger.deprecate ':firefox_options', 'Selenium::WebDriver::Firefox::Options'
70
- firefox_options.each do |key, value|
71
- options.add_option(key, value)
72
- end
73
- end
74
-
75
- profile = opts.delete(:profile)
76
- if profile
77
- WebDriver.logger.deprecate ':profile', 'Selenium::WebDriver::Firefox::Options#profile='
78
- options.profile = profile
79
- end
80
-
81
- options = options.as_json
82
- caps.merge!(options) unless options.empty?
83
-
84
- caps
85
- end
86
- end # Driver
87
- end # Marionette
88
- end # Firefox
89
- end # WebDriver
90
- end # Selenium