Reputation: 11
I am using HtmlUnit for automated testing of my web application that application is not working properly because of asynchronous nature of ajax. I used NicelyResynchronizingAjaxController but it seems it is not working because my application is using multiple threads for retieving data.
Is there any alternative. Thanks in advance.
Upvotes: 1
Views: 419
Reputation: 487
Try to call.
webClient.waitForBackgroundJavaScript(10000);
or
webClient.waitForBackgroundJavaScriptStartingBefore(10000);
before accessing fields modified via ajax.
If that don't solve try to explicitly wait for a condition that is expected be fulfilled when your JavaScript runs
for (int i = 0; i < 20; i++) {
if (condition_to_happen_after_js_execution) {
break;
}
synchronized (page) {
page.wait(500);
}
}
Upvotes: 2