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
Class Attribute Summary collapse
- .executable ⇒ Object readonly private
- .missing_text ⇒ Object readonly private
Instance Attribute Summary collapse
- #host ⇒ Object private
Instance Method Summary collapse
- #binary_path(path) ⇒ Object private
-
#initialize(executable_path, port, driver_opts) ⇒ Service
constructor
private
A new instance of Service.
- #start ⇒ Object private
- #stop ⇒ Object private
- #uri ⇒ Object private
Constructor Details
#initialize(executable_path, port, driver_opts) ⇒ 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.
48 49 50 51 52 53 54 55 |
# File 'lib/selenium/webdriver/common/service.rb', line 48 def initialize(executable_path, port, driver_opts) @executable_path = binary_path(executable_path) @host = Platform.localhost @port = Integer(port) @extra_args = extract_service_args(driver_opts) raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1 end |
Class Attribute Details
.executable ⇒ Object (readonly)
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.
43 44 45 |
# File 'lib/selenium/webdriver/common/service.rb', line 43 def executable @executable end |
.missing_text ⇒ Object (readonly)
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.
43 44 45 |
# File 'lib/selenium/webdriver/common/service.rb', line 43 def missing_text @missing_text 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.
46 47 48 |
# File 'lib/selenium/webdriver/common/service.rb', line 46 def host @host end |
Instance Method Details
#binary_path(path) ⇒ 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.
57 58 59 60 61 62 |
# File 'lib/selenium/webdriver/common/service.rb', line 57 def binary_path(path) path = Platform.find_binary(self.class.executable) if path.nil? raise Error::WebDriverError, self.class.missing_text unless path Platform.assert_executable path path end |
#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.
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/selenium/webdriver/common/service.rb', line 64 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.
78 79 80 81 82 83 84 |
# File 'lib/selenium/webdriver/common/service.rb', line 78 def stop stop_server @process.poll_for_exit STOP_TIMEOUT rescue ChildProcess::TimeoutError 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.
86 87 88 |
# File 'lib/selenium/webdriver/common/service.rb', line 86 def uri @uri ||= URI.parse("http://#{@host}:#{@port}") end |