Class: Selenium::WebDriver::Chrome::Service Private
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Chrome::Service
- Defined in:
- lib/selenium/webdriver/chrome/service.rb
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.
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.
5
- DEFAULT_PORT =
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.
9515
- MISSING_TEXT =
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.
"Unable to find the chromedriver executable. Please download the server from http://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH. More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver."
Class Method Summary collapse
- .default_service(*extra_args) ⇒ Object private
- .executable_path ⇒ Object private
- .executable_path=(path) ⇒ 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.
54 55 56 57 58 59 60 61 62 |
# File 'lib/selenium/webdriver/chrome/service.rb', line 54 def initialize(executable_path, port, *extra_args) @executable_path = executable_path @host = Platform.localhost @port = Integer(port) raise Error::WebDriverError, "invalid port: #{@port}" if @port < 1 @extra_args = extra_args end |
Class Method Details
.default_service(*extra_args) ⇒ 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 |
# File 'lib/selenium/webdriver/chrome/service.rb', line 50 def self.default_service(*extra_args) new executable_path, DEFAULT_PORT, *extra_args end |
.executable_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.
35 36 37 38 39 40 41 42 43 |
# File 'lib/selenium/webdriver/chrome/service.rb', line 35 def self.executable_path @executable_path ||= ( path = Platform.find_binary "chromedriver" path or raise Error::WebDriverError, MISSING_TEXT Platform.assert_executable path path ) end |
.executable_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.
45 46 47 48 |
# File 'lib/selenium/webdriver/chrome/service.rb', line 45 def self.executable_path=(path) Platform.assert_executable path @executable_path = path 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.
64 65 66 67 68 69 70 71 72 |
# File 'lib/selenium/webdriver/chrome/service.rb', line 64 def start 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.
74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/selenium/webdriver/chrome/service.rb', line 74 def stop return if @process.nil? || @process.exited? Net::HTTP.start(@host, @port) do |http| http.open_timeout = STOP_TIMEOUT / 2 http.read_timeout = STOP_TIMEOUT / 2 http.get("/shutdown") end 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.
87 88 89 |
# File 'lib/selenium/webdriver/chrome/service.rb', line 87 def uri URI.parse "http://#{@host}:#{@port}" end |