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!