Class: Selenium::WebDriver::Service
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Service
- Defined in:
- rb/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
#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 'rb/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
.driver_path ⇒ Object
Returns the value of attribute driver_path.
29 30 31 |
# File 'rb/lib/selenium/webdriver/common/service.rb', line 29 def driver_path @driver_path end |
Instance Attribute Details
#args ⇒ Object Also known as: extra_args
Returns the value of attribute args.
60 61 62 |
# File 'rb/lib/selenium/webdriver/common/service.rb', line 60 def args @args end |
#executable_path ⇒ Object
Returns the value of attribute executable_path.
60 61 62 |
# File 'rb/lib/selenium/webdriver/common/service.rb', line 60 def executable_path @executable_path end |
#host ⇒ Object
Returns the value of attribute host.
60 61 62 |
# File 'rb/lib/selenium/webdriver/common/service.rb', line 60 def host @host end |
#log ⇒ Object
Returns the value of attribute log.
60 61 62 |
# File 'rb/lib/selenium/webdriver/common/service.rb', line 60 def log @log end |
#port ⇒ Object
Returns the value of attribute port.
60 61 62 |
# File 'rb/lib/selenium/webdriver/common/service.rb', line 60 def port @port end |
Class Method Details
.chrome(**opts) ⇒ Object
31 32 33 |
# File 'rb/lib/selenium/webdriver/common/service.rb', line 31 def chrome(**opts) Chrome::Service.new(**opts) end |
.edge(**opts) ⇒ Object Also known as: microsoftedge, msedge
44 45 46 |
# File 'rb/lib/selenium/webdriver/common/service.rb', line 44 def edge(**opts) Edge::Service.new(**opts) end |
.firefox(**opts) ⇒ Object
35 36 37 |
# File 'rb/lib/selenium/webdriver/common/service.rb', line 35 def firefox(**opts) Firefox::Service.new(**opts) end |
Instance Method Details
#env_path ⇒ Object
104 105 106 |
# File 'rb/lib/selenium/webdriver/common/service.rb', line 104 def env_path ENV.fetch(self.class::DRIVER_PATH_ENV_KEY, nil) end |
#find_driver_path ⇒ Object
99 100 101 102 |
# File 'rb/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 |
#launch ⇒ Object
90 91 92 93 |
# File 'rb/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 ⇒ Object
95 96 97 |
# File 'rb/lib/selenium/webdriver/common/service.rb', line 95 def shutdown_supported self.class::SHUTDOWN_SUPPORTED end |