Class: Selenium::WebDriver::Service Private
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Service
- Defined in:
- lib/selenium/webdriver/common/service.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Base class implementing default behavior of service object, responsible for starting and stopping driver implementations.
Subclasses must implement the following private methods:
* #start_process
* #stop_server
* #cannot_connect_error_text
Direct Known Subclasses
Chrome::Service, Edge::Service, Firefox::Service, IE::Service, PhantomJS::Service, Selenium::WebDriver::Safari::Service
Constant Summary collapse
- START_TIMEOUT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
20- SOCKET_LOCK_TIMEOUT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
45- STOP_TIMEOUT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
20
Instance Attribute Summary collapse
- #host ⇒ Object private
Instance Method Summary collapse
-
#initialize(executable_path, port, *extra_args) ⇒ Service
constructor
private
A new instance of Service.
- #start ⇒ Object private
- #stop ⇒ Object private
- #uri ⇒ Object private
Constructor Details
#initialize(executable_path, port, *extra_args) ⇒ 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.
Returns a new instance of Service.
41 42 43 44 45 46 47 48 |
# File 'lib/selenium/webdriver/common/service.rb', line 41 def initialize(executable_path, port, *extra_args) @executable_path = executable_path @host = Platform.localhost @port = Integer(port) @extra_args = extra_args raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1 end |
Instance Attribute Details
#host ⇒ Object
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.
39 40 41 |
# File 'lib/selenium/webdriver/common/service.rb', line 39 def host @host end |
Instance Method Details
#start ⇒ Object
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.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/selenium/webdriver/common/service.rb', line 50 def start if process_running? raise "already started: #{uri.inspect} #{@executable_path.inspect}" end Platform.exit_hook { stop } # make sure we don't leave the server running socket_lock.locked do find_free_port start_process connect_until_stable end end |
#stop ⇒ Object
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.
64 65 66 67 68 69 |
# File 'lib/selenium/webdriver/common/service.rb', line 64 def stop return if process_exited? stop_server ensure stop_process end |
#uri ⇒ Object
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.
71 72 73 |
# File 'lib/selenium/webdriver/common/service.rb', line 71 def uri @uri ||= URI.parse("http://#{@host}:#{@port}") end |