       chromedriver.stderr.on "close", ->
         resolve(errorCode)
 
-  waits(5000)
+  waitsFor("webdriver to start", pollChromeDriver, 5000)
 
   waitsFor("webdriver to finish", (done) ->
     finish = once ->

path = require "path"
temp = require("temp").track()
remote = require "remote"
async = require "async"

ChromedriverPath = path.resolve(__dirname, '..', '..', '..', 'atom-shell', 'chromedriver', 'chromedriver')
SocketPath = path.join(temp.mkdirSync("socket-dir"), "atom-#{process.env.USER}.sock")
ChromedriverPort = 9515
ChromedriverURLBase = "/wd/hub"
ChromedriverStatusURL = "http://localhost:#{ChromedriverPort}#{ChromedriverURLBase}/status"

pollChromeDriver = (done) ->
  http.get(ChromedriverStatusURL, (response) ->
    if response.statusCode is 200
      done()
    else
      pollChromeDriver(done)
  )

buildAtomClient = (args, env) ->
  client = webdriverio.remote(
