diff --git a/java/client/src/org/openqa/selenium/internal/seleniumemulation/WaitForPageToLoad.java b/java/client/src/org/openqa/selenium/internal/seleniumemulation/WaitForPageToLoad.java index b26efa58cb453..5f4ebc469d3ff 100644 --- a/java/client/src/org/openqa/selenium/internal/seleniumemulation/WaitForPageToLoad.java +++ b/java/client/src/org/openqa/selenium/internal/seleniumemulation/WaitForPageToLoad.java @@ -49,7 +49,10 @@ protected Void handleSeleneseCommand(final WebDriver driver, String timeout, Str public boolean until() { try { Object result = ((JavascriptExecutor) driver).executeScript( - "return document['readyState'] ? 'complete' == document.readyState : true"); + // TODO(simon): Extract the readystate jar and use that + "if (document['readyState']) { return 'complete' == document.readyState; }\n" + + "if (document.all) { return document.all.length > 0; }\n" + + "return true;"); if (result != null && result instanceof Boolean && (Boolean) result) { long now = System.currentTimeMillis(); if (now - started > timeToWait) {