Object
@api private
# File lib/selenium/webdriver/phantomjs/service.rb, line 27 def self.default_service new executable_path, PortProber.above(DEFAULT_PORT) end
# File lib/selenium/webdriver/phantomjs/service.rb, line 17 def self.executable_path @executable_path ||= ( path = PhantomJS.path path or raise Error::WebDriverError, MISSING_TEXT Platform.assert_executable path path ) end
# File lib/selenium/webdriver/phantomjs/service.rb, line 31 def initialize(executable_path, port) @uri = URI.parse "http://#{Platform.localhost}:#{port}" server_command = [executable_path, "--webdriver=#{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/phantomjs/service.rb, line 41 def start @process.start unless @socket_poller.connected? raise Error::WebDriverError, "unable to connect to phantomjs @ #{@uri} after #{START_TIMEOUT} seconds" end Platform.exit_hook { stop } # make sure we don't leave the server running end
# File lib/selenium/webdriver/phantomjs/service.rb, line 51 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.get("/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.