0

I have the same problem as posted in this topic: HTMLUnit doesn't wait for Javascript The solution partly helped (using BrowserVersion.FIREFOX_24), as previously page wasn't even displayed properly, at least now is, however I'm stuck on ...Loading... message, which i checked in browser and it takes up to 10 seconds to show results. Then I tried to use other code posted there, so my looks pretty much like this:

HtmlPage htmlPage = null;
try {
  htmlPage = submit.click();
  int i = webClient.waitForBackgroundJavaScript(1000);
  while (i > 0)
  {
    i = webClient.waitForBackgroundJavaScript(1000);
    System.out.println(i);

    if (i == 0)
    {
      break;
    }
    synchronized (htmlPage)
    {
      System.out.println("wait");
      try {
        htmlPage.wait(500);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }
  }
} catch (IOException e) {
  e.printStackTrace();
}   

By clicking, I'm submitting the form. Any ideas? Im new in HtmlUnit, so please be lenient. Thank you so much!

1 Answer 1

1

I think you're overcomplicating this. Additionally, I wouldn't recommend using the waitForBackgroundJavaScript method either. Furthermore, the HTMLUnit API itself doesn't recommend it.

I've explained in this question a better and simpler way to work with AJAX:

Get the changed HTML content after it's updated by Javascript? (htmlunit)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.