Skip to content

Commit

Permalink
A better fix for service availability checking that works for both Ch…
Browse files Browse the repository at this point in the history
…rome and Marionette
  • Loading branch information
barancev committed Oct 9, 2015
1 parent ffb124c commit 06a8a62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;

/**
* Manages the life and death of an GeckoDriver aka 'wires'.
Expand Down Expand Up @@ -63,6 +64,11 @@ public static GeckoDriverService createDefaultService() {
return new Builder().usingAnyFreePort().build();
}

@Override
protected void waitUntilAvailable() throws MalformedURLException {
return;
}

/**
* Builder used to configure new {@link GeckoDriverService} instances.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,19 @@ public void start() throws IOException {
process.copyOutputTo(System.err);
process.executeAsync();

waitUntilAvailable();
} finally {
lock.unlock();
}
}

protected void waitUntilAvailable() throws MalformedURLException {
try {
URL status = new URL(url.toString() + "/status");
new UrlChecker().waitUntilAvailable(20, SECONDS, status);
} catch (UrlChecker.TimeoutException e) {
process.checkForError();
throw new WebDriverException("Timed out waiting for driver server to start.", e);
} finally {
lock.unlock();
}
}

Expand Down

0 comments on commit 06a8a62

Please sign in to comment.