Object
@api private
# File lib/selenium/webdriver/chrome/service.rb, line 32 def self.default_service new executable_path, PortProber.above(DEFAULT_PORT) end
# File 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
# File lib/selenium/webdriver/chrome/service.rb, line 27 def self.executable_path=(path) Platform.assert_executable path @executable_path = path end
# File lib/selenium/webdriver/chrome/service.rb, line 36 def initialize(executable_path, port) @uri = URI.parse "http://#{Platform.localhost}:#{port}" server_command = [executable_path, "--port=#{port}"] @process = ChildProcess.build(*server_command) @socket_poller = SocketPoller.new Platform.localhost, port, START_TIMEOUT @process.io.inherit! if $DEBUG == true end
# File 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
# File 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
Generated with the Darkfish Rdoc Generator 2.