From: Elise L. <el...@ch...> - 2004-06-24 00:45:28
|
Ah, i found the problem (by successive removal of javascript)... top.cudl.onYearChange() was doing this: document.myform.action = "StartCUDL.jsp?Year=" + document.myform.Year[document.myform.Year.selectedIndex].value; document.myform.submit(); and this index didn't evaluate properly. If I hardcode the index, it seems to work. Thx Elise > -----Original Message----- > From: Elise Lebeau > Sent: Wednesday, June 23, 2004 5:02 PM > To: 'br...@br...' > Cc: 'htm...@li...' > Subject: RE: [Htmlunit-user] Excecuting Javascript within a Frame > > > here's my html: > > ... > <script language = "Javascript" type="text/javascript"> > function year() > { > top.cudl.document.forms[0].elements[0].value="2005"; > top.cudl.onYearChange(); > } > > </script> > </head> > <body> > testRequestAQuote > <form name="myYear" action="javascript:year();"> > <button type="submit" name="yearButton">year</button> > </form> > ... > > Here is my JUnit test case: > > public void testModelSelector() { > try { > final WebClient webClient = new WebClient(); > final URL url = new > URL(url"http://127.0.0.1:8080/cudl/cudlQA.html"); > > // Get the first page > final HtmlPage page1 = (HtmlPage)webClient.getPage(url); > > final List list = page1.getFrames(); > final HtmlFrame frame2 = (HtmlFrame)list.get(1); > final HtmlPage test = (HtmlPage)frame2.getEnclosedPage(); > test.getFormByName("myYear").submit(); > > } catch (Exception e) { > e.printStackTrace(); > fail("got exception"); > } > > } > > > > Elise > > > > > I'm evaluating htmlunit and am running into a pretty basic > > problem. I > > > can't submit a form that has a javascript action. Do I need to do > > > some init for JavaScript to work? I am using 1.3pre and > this is my > > > code: > > > > > > final WebClient webClient = new WebClient(); > > > final URL url = new URL(url); > > > > > > final HtmlPage page1 = > (HtmlPage)webClient.getPage(url); > > > final List list = page1.getFrames(); > > > final HtmlFrame frame2 = (HtmlFrame)list.get(1); > > > final HtmlPage test = > > (HtmlPage)frame2.getEnclosedPage(); > > > test.getFormByName("myYear").submit(); > > > > > > this is the stack: > > > com.gargoylesoftware.htmlunit.ScriptException: DomNode > has not been > > > set for this SimpleScriptable: > > > com.gargoylesoftware.htmlunit.javascript.host.Select > > > at > > > > > com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine.exec > > ute(JavaScript > > > Engine.java:264) > > > at > > > > > com.gargoylesoftware.htmlunit.html.HtmlPage.executeJavaScriptI > > fPossible(Html > > > Page.java:700) > > > at > > > com.gargoylesoftware.htmlunit.html.HtmlForm.submit(HtmlForm.java:156) > > > at > > > com.gargoylesoftware.htmlunit.html.HtmlForm.submit(HtmlForm.java:130) > > > at > > > com.chrome.cudlpsg.CUDLWBTests.testModelSelector(CUDLWBTests.java:75) > > > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) at > > > > > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccess > > orImpl.java:39 > > > ) > > > at > > > > > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMeth > > odAccessorImpl > > > .java:25) > > > at java.lang.reflect.Method.invoke(Method.java:324) > > > at junit.framework.TestCase.runTest(TestCase.java:154) > > > at junit.framework.TestCase.runBare(TestCase.java:127) > > > at junit.framework.TestResult$1.protect(TestResult.java:106) > > > at junit.framework.TestResult.runProtected(TestResult.java:124) > > > at junit.framework.TestResult.run(TestResult.java:109) > > > at junit.framework.TestCase.run(TestCase.java:118) > > > at junit.framework.TestSuite.runTest(TestSuite.java:208) > > > at junit.framework.TestSuite.run(TestSuite.java:203) > > > at junit.textui.TestRunner.doRun(TestRunner.java:116) > > > at > > > com.intellij.rt.execution.junit2.IdeaJUnitAgent.doRun(Unknown Source) > > > at junit.textui.TestRunner.start(TestRunner.java:172) > > > at > > > > > com.intellij.rt.execution.junit.TextTestRunner2.startRunnerWit > > hArgs(Unknown > > > Source) > > > at > > > > > com.intellij.rt.execution.junit2.JUnitStarter.prepareStreamsAn > > dStart(Unknown > > > Source) > > > at > > com.intellij.rt.execution.junit2.JUnitStarter.main(Unknown Source) > > > > > > > > > > > > Elise Lebeau > > > Software Engineer > > > Chrome Systems Corporation > > > email: <mailto:me...@ch...> el...@ch... > > > phone: 503.963.6320 > > > Fax: 503.963.6310 > > > > > > > > > > > > |