class Selenium::WebDriver::Service

Base class implementing default behavior of service object, responsible for storing a service manager configuration.

Attributes

driver_path[R]
args[RW]
executable_path[RW]
extra_args[RW]
host[RW]
log[RW]
port[RW]

Public Class Methods

chrome(**opts) click to toggle source
# File lib/selenium/webdriver/common/service.rb, line 31
def chrome(**opts)
  Chrome::Service.new(**opts)
end
driver_path=(path) click to toggle source
# File lib/selenium/webdriver/common/service.rb, line 54
def driver_path=(path)
  Platform.assert_executable path if path.is_a?(String)
  @driver_path = path
end
edge(**opts) click to toggle source
# File lib/selenium/webdriver/common/service.rb, line 44
def edge(**opts)
  Edge::Service.new(**opts)
end
Also aliased as: microsoftedge, msedge
firefox(**opts) click to toggle source
# File lib/selenium/webdriver/common/service.rb, line 35
def firefox(**opts)
  Firefox::Service.new(**opts)
end
ie(**opts) click to toggle source
# File lib/selenium/webdriver/common/service.rb, line 39
def ie(**opts)
  IE::Service.new(**opts)
end
Also aliased as: internet_explorer
internet_explorer(**opts)
Alias for: ie
microsoftedge(**opts)
Alias for: edge
msedge(**opts)
Alias for: edge
new(path: nil, port: nil, log: nil, args: nil) click to toggle source

End users should use a class method for the desired driver, rather than using this directly.

@api private

# File lib/selenium/webdriver/common/service.rb, line 69
def initialize(path: nil, port: nil, log: nil, args: nil)
  port ||= self.class::DEFAULT_PORT
  args ||= []
  path ||= env_path

  @executable_path = path
  @host = Platform.localhost
  @port = Integer(port)
  @log = case log
         when :stdout
           $stdout
         when :stderr
           $stderr
         else
           log
         end
  @args = args

  raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1
end
safari(**opts) click to toggle source
# File lib/selenium/webdriver/common/service.rb, line 50
def safari(**opts)
  Safari::Service.new(**opts)
end

Public Instance Methods

env_path() click to toggle source
# File lib/selenium/webdriver/common/service.rb, line 104
def env_path
  ENV.fetch(self.class::DRIVER_PATH_ENV_KEY, nil)
end
find_driver_path() click to toggle source
# File lib/selenium/webdriver/common/service.rb, line 99
def find_driver_path
  default_options = WebDriver.const_get("#{self.class.name&.split('::')&.[](2)}::Options").new
  DriverFinder.new(default_options, self).driver_path
end
launch() click to toggle source
# File lib/selenium/webdriver/common/service.rb, line 90
def launch
  @executable_path ||= env_path || find_driver_path
  ServiceManager.new(self).tap(&:start)
end
shutdown_supported() click to toggle source
# File lib/selenium/webdriver/common/service.rb, line 95
def shutdown_supported
  self.class::SHUTDOWN_SUPPORTED
end