I would try a setup solution
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
this will cause the synchronization of all ajax calls.
Alternatively, did you try in your decision to call "webClient.waitForBackgroundJavaScript (10000)" after it received the page?
Something like that:
final HtmlPage page2 = button.click(); webClient.waitForBackgroundJavaScript(10000) String originalHtml = page2.asXml(); return originalHtml;
Also use htmlunit 2.13
source share