From: Ruff, T. <Tho...@so...> - 2014-02-08 06:13:40
|
No, I was testing against the latest stable release (2.13). I'll try using the latest snapshot on Monday. The url is not public and I didn't write the GWT code but I'll see if I can create a minimal version of it that produces the problem. It may take some time to get that approved though. Thanks Ahmed. Tom ________________________________ From: Ahmed Ashour [asa...@ya...] Sent: Thursday, February 06, 2014 5:53 PM To: htm...@li... Cc: htm...@li... Subject: Re: [Htmlunit-user] Trouble testing a GWT application Hi Tom, Hope you are you latest HtmlUnit version/snapshot. GWT AJAX example is correctly handled. Is there a way to send the public URL of the web app? Or you can send the whole project so others can see. Ahmed On Feb 7, 2014, at 4:00 AM, "Ruff, Thomas" <Tho...@so...<mailto:Tho...@so...>> wrote: I'm trying to test a GWT application by filling out some input fields and clicking on a button. When I do this in IE or Chrome the outputDiv I'm looking for is modified via AJAX after clicking on the Calculate button but when I run my test case that div is left unmodified (its original text node value is left unchanged). I've tried waitForBackgroundJavaScript(), waitForBackgroundJavaScriptStartingBefore(), wait() and sleep(), but nothing seems to make a difference. Has anyone else been able to succeed in testing GWT pages that modify themselves with the result of AJAX calls? Do you see anything wrong with my test? public class MyTest { @Test public void calcDensityAltitude() throws Exception { WebClient webClient = new WebClient(BrowserVersion.INTERNET_EXPLORER_8); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); HtmlPage page = webClient.getPage("http://mypage"); page.getWebClient().waitForBackgroundJavaScript(10000); try { //set input fields HtmlInput elevation = page.getHtmlElementById("myId"); elevation.setValueAttribute("30.0"); HtmlDivision calButton = page.getFirstByXPath("//*[text()='Calculate']"); page.getWebClient().waitForBackgroundJavaScript(10000); page = calButton.click(); page.getWebClient().waitForBackgroundJavaScript(10000); //try 20 times to wait .5 second each for filling the page. HtmlLabel outputDiv=null; for (int i = 0; i < 20; i++) { outputDiv = page.getFirstByXPath("//*[text()='11422']"); if (null != outputDiv) { break; } synchronized (page) { //also tried to sleep() instead page.wait(500); } } int remainingTasks = page.getWebClient().waitForBackgroundJavaScript(10000); System.out.println("remaining JS tasks: " + remainingTasks); System.out.println(page.asXml()); Assert.assertNotNull(outputDiv); String output = outputDiv.getTextContent(); System.out.println("Desity Altitude: " + output); } catch (...) {...} webClient.closeAllWindows(); } } Thanks, Tom |