Class: Selenium::WebDriver::Chrome::Service Private
- Inherits:
-
Object
- Object
- Selenium::WebDriver::Chrome::Service
- Defined in:
- rb/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
- 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
- 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 http://code.google.com/p/selenium/wiki/ChromeDriver."
Instance Attribute Summary (collapse)
- - (Object) uri readonly private
Class Method Summary (collapse)
- + (Object) default_service(*extra_args) private
- + (Object) executable_path private
- + (Object) executable_path=(path) private
Instance Method Summary (collapse)
-
- (Service) initialize(executable_path, port, *extra_args)
constructor
private
A new instance of Service.
- - (Object) start private
- - (Object) stop private
Constructor Details
- (Service) initialize(executable_path, port, *extra_args)
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
36 37 38 39 40 41 42 43 44 |
# File 'rb/lib/selenium/webdriver/chrome/service.rb', line 36 def initialize(executable_path, port, *extra_args) @uri = URI.parse "http://#{Platform.localhost}:#{port}" server_command = [executable_path, "--port=#{port}", *extra_args] @process = ChildProcess.build(*server_command) @socket_poller = SocketPoller.new Platform.localhost, port, START_TIMEOUT @process.io.inherit! if $DEBUG == true end |
Instance Attribute Details
- (Object) uri (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.
15 16 17 |
# File 'rb/lib/selenium/webdriver/chrome/service.rb', line 15 def uri @uri end |
Class Method Details
+ (Object) default_service(*extra_args)
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.
32 33 34 |
# File 'rb/lib/selenium/webdriver/chrome/service.rb', line 32 def self.default_service(*extra_args) new executable_path, PortProber.above(DEFAULT_PORT), *extra_args end |
+ (Object) executable_path
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.
17 18 19 20 21 22 23 24 25 |
# File 'rb/lib/selenium/webdriver/chrome/service.rb', line 17 def self.executable_path @executable_path ||= ( path = Platform.find_binary "chromedriver" path or raise Error::WebDriverError, MISSING_TEXT Platform.assert_executable path path ) end |
+ (Object) executable_path=(path)
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.
27 28 29 30 |
# File 'rb/lib/selenium/webdriver/chrome/service.rb', line 27 def self.executable_path=(path) Platform.assert_executable path @executable_path = path end |
Instance Method Details
- (Object) start
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 49 50 51 52 53 54 |
# File 'rb/lib/selenium/webdriver/chrome/service.rb', line 46 def start @process.start unless @socket_poller.connected? raise Error::WebDriverError, "unable to connect to chromedriver #{@uri}" end Platform.exit_hook { stop } # make sure we don't leave the server running end |
- (Object) stop
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.
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'rb/lib/selenium/webdriver/chrome/service.rb', line 56 def stop return if @process.nil? || @process.exited? Net::HTTP.start(uri.host, uri.port) do |http| http.open_timeout = STOP_TIMEOUT / 2 http.read_timeout = STOP_TIMEOUT / 2 http.head("/shutdown") end @process.poll_for_exit STOP_TIMEOUT rescue ChildProcess::TimeoutError # ok, force quit @process.stop STOP_TIMEOUT end |