lib/selenium/webdriver/firefox/driver.rb in selenium-webdriver-4.7.1 vs lib/selenium/webdriver/firefox/driver.rb in selenium-webdriver-4.8.0
- old
+ new
@@ -18,11 +18,10 @@
# under the License.
module Selenium
module WebDriver
module Firefox
-
#
# Driver implementation for Firefox using GeckoDriver.
# @api private
#
@@ -35,28 +34,46 @@
DriverExtensions::HasLogEvents,
DriverExtensions::HasNetworkInterception,
DriverExtensions::HasWebStorage,
DriverExtensions::PrintsPage].freeze
+ def initialize(capabilities: nil, options: nil, service: nil, url: nil, **opts)
+ raise ArgumentError, "Can't initialize #{self.class} with :url" if url
+
+ caps = process_options(options, capabilities)
+ url = service_url(service || Service.firefox)
+ super(caps: caps, url: url, **opts)
+ end
+
def browser
:firefox
end
private
def devtools_url
if capabilities['moz:debuggerAddress'].nil?
- raise(Error::WebDriverError, "DevTools is not supported by this version of Firefox; use v85 or higher")
+ raise(Error::WebDriverError, 'DevTools is not supported by this version of Firefox; use v85 or higher')
end
uri = URI("http://#{capabilities['moz:debuggerAddress']}")
response = Net::HTTP.get(uri.hostname, '/json/version', uri.port)
JSON.parse(response)['webSocketDebuggerUrl']
end
def devtools_version
Firefox::DEVTOOLS_VERSION
+ end
+
+ def process_options(options, capabilities)
+ if options && !options.is_a?(Options)
+ raise ArgumentError, ":options must be an instance of #{Options}"
+ elsif options.nil? && capabilities.nil?
+ options = Options.new
+ end
+
+ super(options, capabilities)
end
end # Driver
end # Firefox
end # WebDriver
end # Selenium