title: Selenium webdriver execution gets stuck due to a javascript wait condition
body: <p>I have been using a java-script wait condition to wait for page load and my code is like this:</p>
  
  <pre><code>public void untilPageIsLoaded() {
          ExpectedCondition&lt;Boolean&gt; condition = new ExpectedCondition&lt;Boolean&gt;() {
              public Boolean apply(WebDriver driver) {
                  return ((JavascriptExecutor) driver).executeScript("return document.readyState").equals("complete");
              }
          };
          WebDriverWait wait = new WebDriverWait(driver, timeout);
          wait.until(condition);
      }
  </code></pre>
  
  <p>Initially this code was working very well but few days later my tests started getting stuck at random points. So I investigated the issue and came to know that the culprit is above java-script wait condition which stops execution.</p>
  
  <p>Even I was not getting any exception and it never timeout.I know this is very strange but this is not only with me, have a look here; </p>
  
  <p><a href="https://code.google.com/p/selenium/issues/detail?id=6955" rel="nofollow noreferrer">https://code.google.com/p/selenium/issues/detail?id=6955</a></p>
  
  <p>I tried with Upgraded/downgraded version of selenium and browser,changed system configuration but none of them worked.</p>
  
  <p>Now I want to replace above java-script wait condition with some other code.I don't want to use <code>thread.sleep();</code> </p>
  
  <p>Please suggest me something good.</p>