Class: Selenium::WebDriver::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/selenium/webdriver/common/service.rb

Overview

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

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path: nil, port: nil, args: nil) ⇒ Service

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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


68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/selenium/webdriver/common/service.rb', line 68

def initialize(path: nil, port: nil, args: nil)
  path ||= self.class.driver_path
  port ||= self.class::DEFAULT_PORT
  args ||= []

  @executable_path = binary_path(path)
  @host = Platform.localhost
  @port = Integer(port)

  @extra_args = args.is_a?(Hash) ? extract_service_args(args) : args

  raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1
end

Class Attribute Details

.driver_pathObject

Returns the value of attribute driver_path.


29
30
31
# File 'lib/selenium/webdriver/common/service.rb', line 29

def driver_path
  @driver_path
end

Instance Attribute Details

#executable_pathObject (readonly)

Returns the value of attribute executable_path.


60
61
62
# File 'lib/selenium/webdriver/common/service.rb', line 60

def executable_path
  @executable_path
end

#extra_argsObject (readonly)

Returns the value of attribute extra_args.


60
61
62
# File 'lib/selenium/webdriver/common/service.rb', line 60

def extra_args
  @extra_args
end

#hostObject

Returns the value of attribute host.


59
60
61
# File 'lib/selenium/webdriver/common/service.rb', line 59

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.


60
61
62
# File 'lib/selenium/webdriver/common/service.rb', line 60

def port
  @port
end

Class Method Details

.chrome(**opts) ⇒ Object


31
32
33
# File 'lib/selenium/webdriver/common/service.rb', line 31

def chrome(**opts)
  Chrome::Service.new(**opts)
end

.edge(**opts) ⇒ Object Also known as: microsoftedge


44
45
46
# File 'lib/selenium/webdriver/common/service.rb', line 44

def edge(**opts)
  Edge::Service.new(**opts)
end

.firefox(**opts) ⇒ Object


35
36
37
# File 'lib/selenium/webdriver/common/service.rb', line 35

def firefox(**opts)
  Firefox::Service.new(**opts)
end

.ie(**opts) ⇒ Object Also known as: internet_explorer


39
40
41
# File 'lib/selenium/webdriver/common/service.rb', line 39

def ie(**opts)
  IE::Service.new(**opts)
end

.safari(**opts) ⇒ Object


49
50
51
# File 'lib/selenium/webdriver/common/service.rb', line 49

def safari(**opts)
  Safari::Service.new(**opts)
end

Instance Method Details

#launchObject


82
83
84
85
86
# File 'lib/selenium/webdriver/common/service.rb', line 82

def launch
  sm = ServiceManager.new(self)
  sm.start
  sm
end

#shutdown_supportedObject


88
89
90
# File 'lib/selenium/webdriver/common/service.rb', line 88

def shutdown_supported
  self.class::SHUTDOWN_SUPPORTED
end