开发者

ajax testing using htmlunit

I am using HtmlUnit for automated testing of my web applica开发者_StackOverflow社区tion 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.


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);
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜