class Selenium::WebDriver::Remote::Driver

def devtools_url

def devtools_url
  capabilities['se:cdp']
end

def devtools_version

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

def initialize(capabilities: nil, options: nil, service: nil, url: nil, **opts)

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 }
end

def process_options(options, capabilities)

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