Class: Selenium::WebDriver::Service
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Service
- Defined in:
- lib/selenium/webdriver/common/service.rb
Overview
Base class implementing default behavior of service object, responsible for storing a service manager configuration.
Direct Known Subclasses
Chrome::Service, Edge::Service, Firefox::Service, IE::Service, Selenium::WebDriver::Safari::Service
Class Attribute Summary collapse
-
.driver_path ⇒ Object
Returns the value of attribute driver_path.
Instance Attribute Summary collapse
-
#args ⇒ Object
(also: #extra_args)
Returns the value of attribute args.
-
#executable_path ⇒ Object
Returns the value of attribute executable_path.
-
#host ⇒ Object
Returns the value of attribute host.
-
#log ⇒ Object
Returns the value of attribute log.
-
#port ⇒ Object
Returns the value of attribute port.
Class Method Summary collapse
- .chrome(**opts) ⇒ Object
- .edge(**opts) ⇒ Object (also: microsoftedge, msedge)
- .firefox(**opts) ⇒ Object
- .ie(**opts) ⇒ Object (also: internet_explorer)
- .safari(**opts) ⇒ Object
Instance Method Summary collapse
- #env_path ⇒ Object
- #find_driver_path ⇒ Object
-
#initialize(path: nil, port: nil, log: nil, args: nil) ⇒ Service
constructor
private
End users should use a class method for the desired driver, rather than using this directly.
- #launch ⇒ Object
- #shutdown_supported ⇒ Object
Constructor Details
permalink #initialize(path: nil, port: nil, log: 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.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# 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 |
Class Attribute Details
permalink .driver_path ⇒ Object
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
permalink #args ⇒ Object Also known as: extra_args
Returns the value of attribute args.
60 61 62 |
# File 'lib/selenium/webdriver/common/service.rb', line 60 def args @args end |
permalink #executable_path ⇒ Object
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 |
permalink #host ⇒ Object
Returns the value of attribute host.
60 61 62 |
# File 'lib/selenium/webdriver/common/service.rb', line 60 def host @host end |
permalink #log ⇒ Object
Returns the value of attribute log.
60 61 62 |
# File 'lib/selenium/webdriver/common/service.rb', line 60 def log @log end |
permalink #port ⇒ Object
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
permalink .chrome(**opts) ⇒ Object
[View source]
31 32 33 |
# File 'lib/selenium/webdriver/common/service.rb', line 31 def chrome(**opts) Chrome::Service.new(**opts) end |
permalink .edge(**opts) ⇒ Object Also known as: microsoftedge, msedge
[View source]
44 45 46 |
# File 'lib/selenium/webdriver/common/service.rb', line 44 def edge(**opts) Edge::Service.new(**opts) end |
permalink .firefox(**opts) ⇒ Object
[View source]
35 36 37 |
# File 'lib/selenium/webdriver/common/service.rb', line 35 def firefox(**opts) Firefox::Service.new(**opts) end |
permalink .ie(**opts) ⇒ Object Also known as: internet_explorer
[View source]
39 40 41 |
# File 'lib/selenium/webdriver/common/service.rb', line 39 def ie(**opts) IE::Service.new(**opts) end |
permalink .safari(**opts) ⇒ Object
[View source]
50 51 52 |
# File 'lib/selenium/webdriver/common/service.rb', line 50 def safari(**opts) Safari::Service.new(**opts) end |
Instance Method Details
permalink #env_path ⇒ Object
[View source]
104 105 106 |
# File 'lib/selenium/webdriver/common/service.rb', line 104 def env_path ENV.fetch(self.class::DRIVER_PATH_ENV_KEY, nil) end |
permalink #find_driver_path ⇒ Object
[View source]
99 100 101 102 |
# File 'lib/selenium/webdriver/common/service.rb', line 99 def find_driver_path = WebDriver.const_get("#{self.class.name&.split('::')&.[](2)}::Options").new DriverFinder.new(, self).driver_path end |
permalink #launch ⇒ Object
[View source]
90 91 92 93 |
# File 'lib/selenium/webdriver/common/service.rb', line 90 def launch @executable_path ||= env_path || find_driver_path ServiceManager.new(self).tap(&:start) end |
permalink #shutdown_supported ⇒ Object
[View source]
95 96 97 |
# File 'lib/selenium/webdriver/common/service.rb', line 95 def shutdown_supported self.class::SHUTDOWN_SUPPORTED end |