class Selenium::WebDriver::Remote::Driver
Driver
implementation for remote server. @api private
Public Class Methods
new(capabilities: nil, options: nil, service: nil, url: nil, **opts)
click to toggle source
Calls superclass method
Selenium::WebDriver::Driver::new
# File lib/selenium/webdriver/remote/driver.rb, line 33 def initialize(capabilities: nil, options: nil, service: nil, url: nil, **opts) raise ArgumentError, "Can not set :service object on #{self.class}" if service url ||= "http://#{Platform.localhost}:4444/wd/hub" caps = process_options(options, capabilities) super(caps: caps, url: url, **opts) @bridge.file_detector = ->((filename, *)) { File.exist?(filename) && filename.to_s } command_list = @bridge.command_list @bridge.extend(WebDriver::Remote::Features) @bridge.add_commands(command_list) end
Private Instance Methods
devtools_url()
click to toggle source
# File lib/selenium/webdriver/remote/driver.rb, line 47 def devtools_url capabilities['se:cdp'] end
devtools_version()
click to toggle source
# File lib/selenium/webdriver/remote/driver.rb, line 51 def devtools_version cdp_version = capabilities['se:cdpVersion']&.split('.')&.first raise Error::WebDriverError, 'DevTools is not supported by the Remote Server' unless cdp_version Integer(cdp_version) end
generate_capabilities(capabilities)
click to toggle source
# File lib/selenium/webdriver/remote/driver.rb, line 68 def generate_capabilities(capabilities) Array(capabilities).map { |cap| if cap.is_a? Symbol cap = WebDriver::Options.send(cap) elsif !cap.respond_to? :as_json msg = ":capabilities parameter only accepts objects responding to #as_json which #{cap.class} does not" raise ArgumentError, msg end cap.as_json }.inject(:merge) end
process_options(options, capabilities)
click to toggle source
# File lib/selenium/webdriver/remote/driver.rb, line 58 def process_options(options, capabilities) if options && capabilities msg = "Don't use both :options and :capabilities when initializing #{self.class}, prefer :options" raise ArgumentError, msg elsif options.nil? && capabilities.nil? raise ArgumentError, "#{self.class} needs :options to be set" end options ? options.as_json : generate_capabilities(capabilities) end