From: Ruff, T. <Tho...@so...> - 2014-02-10 18:29:38
|
I tested against the latest HtmlUnit snapshot (2/9/14) and still have the same problem. GWT is not updating the page via AJAX when the 'Calculate' DIV button is pushed. I'm working on getting a releasable version of the GWT project but in the mean-time I noticed this gets output to the debug console immediately after loading the initial GWT page. It looks like the page's CSS links are failing. Not sure why or if this even matters, but this appears several time in the console window: INFO: statusCode=[404] contentType=[text/html] Feb 10, 2014 10:09:37 AM com.gargoylesoftware.htmlunit.WebClient printContentIfNecessary INFO: <html><head><title>JBoss Web/7.2.2.Final-redhat-1 - JBWEB000064: Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>JBWEB000065: HTTP Status 404 - /metoccalc/undefined</h1><HR size="1" noshade="noshade"><p><b>JBWEB000309: type</b> JBWEB000067: Status report</p><p><b>JBWEB000068: message</b> <u>/metoccalc/undefined</u></p><p><b>JBWEB000069: description</b> <u>JBWEB000124: The requested resource is not available.</u></p><HR size="1" noshade="noshade"><h3>JBoss Web/7.2.2.Final-redhat-1</h3></body></html> Feb 10, 2014 10:09:37 AM com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet loadStylesheet SEVERE: Exception loading http://nn26.nites.itf.spawar.navy.mil:8080/metoccalc/undefined com.gargoylesoftware.htmlunit.FailingHttpStatusCodeException: 404 Not Found for http://nn26.nites.itf.spawar.navy.mil:8080/metoccalc/undefined at com.gargoylesoftware.htmlunit.WebClient.throwFailingHttpStatusCodeExceptionIfNecessary(WebClient.java:496) at com.gargoylesoftware.htmlunit.javascript.host.css.CSSStyleSheet.loadStylesheet(CSSStyleSheet.java:316) at com.gargoylesoftware.htmlunit.javascript.host.html.HTMLLinkElement.getSheet(HTMLLinkElement.java:130) at com.gargoylesoftware.htmlunit.javascript.host.css.StyleSheetList.item(StyleSheetList.java:151) at com.gargoylesoftware.htmlunit.javascript.host.Window.getComputedStyle(Window.java:1601) at com.gargoylesoftware.htmlunit.javascript.host.Element.getCurrentStyle(Element.java:545) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at net.sourceforge.htmlunit.corejs.javascript.MemberBox.invoke(MemberBox.java:120) at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject$GetterSlot.getValue(ScriptableObject.java:320) at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject$RelinkedSlot.getValue(ScriptableObject.java:373) at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.get(ScriptableObject.java:483) at com.gargoylesoftware.htmlunit.javascript.SimpleScriptable.get(SimpleScriptable.java:85) at net.sourceforge.htmlunit.corejs.javascript.ScriptableObject.getProperty(ScriptableObject.java:2296) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1472) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1466) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1241) at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:405) at com.gargoylesoftware.htmlunit.javascript.HtmlUnitContextFactory.doTopCall(HtmlUnitContextFactory.java:309) at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3031) at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:115) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$3.doRun(JavaScriptEngine.java:561) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:669) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:602) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:507) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:570) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.execute(JavaScriptEngine.java:545) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptIfPossible(HtmlPage.java:959) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeInlineScriptIfNeeded(HtmlScript.java:347) at com.gargoylesoftware.htmlunit.html.HtmlScript.executeScriptIfNeeded(HtmlScript.java:425) at com.gargoylesoftware.htmlunit.html.HtmlScript$3.execute(HtmlScript.java:266) at com.gargoylesoftware.htmlunit.html.HtmlScript.onAllChildrenAddedToPage(HtmlScript.java:286) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:683) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.endElement(HTMLParser.java:642) at org.cyberneko.html.HTMLTagBalancer.callEndElement(HTMLTagBalancer.java:1170) at org.cyberneko.html.HTMLTagBalancer.endElement(HTMLTagBalancer.java:1072) at org.cyberneko.html.filters.DefaultFilter.endElement(DefaultFilter.java:206) at org.cyberneko.html.filters.NamespaceBinder.endElement(NamespaceBinder.java:330) at org.cyberneko.html.HTMLScanner$ContentScanner.scanEndElement(HTMLScanner.java:3116) at org.cyberneko.html.HTMLScanner$ContentScanner.scan(HTMLScanner.java:2083) at org.cyberneko.html.HTMLScanner.scanDocument(HTMLScanner.java:918) at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:499) at org.cyberneko.html.HTMLConfiguration.parse(HTMLConfiguration.java:452) at org.apache.xerces.parsers.XMLParser.parse(Unknown Source) at com.gargoylesoftware.htmlunit.html.HTMLParser$HtmlUnitDOMBuilder.parse(HTMLParser.java:899) at com.gargoylesoftware.htmlunit.html.HTMLParser.parse(HTMLParser.java:242) at com.gargoylesoftware.htmlunit.html.HTMLParser.parseHtml(HTMLParser.java:188) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createHtmlPage(DefaultPageCreator.java:268) at com.gargoylesoftware.htmlunit.DefaultPageCreator.createPage(DefaultPageCreator.java:156) at com.gargoylesoftware.htmlunit.WebClient.loadWebResponseInto(WebClient.java:437) at com.gargoylesoftware.htmlunit.WebClient.loadDownloadedResponses(WebClient.java:2024) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.doProcessPostponedActions(JavaScriptEngine.java:712) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.access$500(JavaScriptEngine.java:92) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine$HtmlUnitContextAction.run(JavaScriptEngine.java:679) at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:602) at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:507) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:616) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.callFunction(JavaScriptEngine.java:591) at com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptFunctionIfPossible(HtmlPage.java:985) at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptFunctionJob.runJavaScript(JavaScriptFunctionJob.java:53) at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutionJob.run(JavaScriptExecutionJob.java:102) at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:328) at com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:162) at java.lang.Thread.run(Thread.java:744) Tom ________________________________ From: Ruff, Thomas Sent: Friday, February 07, 2014 10:12 PM To: htm...@li... Subject: RE: [Htmlunit-user] Trouble testing a GWT application 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 |