From: Marc G. <mgu...@ya...> - 2005-08-19 10:23:43
|
your html is not valid (no body, then content inside head, ...) therefore it can't currently be correctly understood by htmlunit. Marc. SALL Ousmane wrote: > Hi, > Sorry, but i think i have found a possible bug with > getEnclosingFormOrDie, I try to click on an element > which is really in a form but I got this message : > testInputs(TestClick)java.lang.IllegalStateException: > Element is not comtained within a form: > HtmlSubmitInput[<input value="FIND" type="submit" > class="btn" id="digiId79">] > at > com.gargoylesoftware.htmlunit.html.HtmlElement.getEnclosingFormOrDie(HtmlElement.java:327) > at > com.gargoylesoftware.htmlunit.html.HtmlSubmitInput.doClickAction(HtmlSubmitInput.java:77) > at > com.gargoylesoftware.htmlunit.html.ClickableElement.click(ClickableElement.java:120) > at TestClick.testInputs(TestClick.java:22) > at > sun.reflect.NativeMethodAccessorImpl.invoke0(Native > Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) > at TestClick.main(TestClick.java:26) > > Thanks for help > The source test is : > public class TestClick extends TestCase { > public void testInputs() throws Exception{ > String > path=racinePath+"/Tests/data/htmlFiles/original.html"; > > > URL url = new URL("file://"+path); > WebClient webClient = new > WebClient(BrowserVersion.INTERNET_EXPLORER_6_0); > HtmlPage page = (HtmlPage)webClient.getPage(url); > HtmlElement htmlElement = > page.getHtmlElementById("digiId79"); > > String str = ((ClickableElement) > htmlElement).click().getWebResponse().getUrl().toExternalForm(); > > } > > public static void main (String[] args) { > junit.textui.TestRunner.run(new > TestSuite(TestClick.class)); > } > } > and the "Original.html" > <HTML id="digiId0"> > <HEAD id="digiId1"> > <TR id="digiId69"> > <TD align="center" id="digiId70"> > <TABLE border="0" cellspacing="0" cellpadding="2" > id="digiId71"> > <TR id="digiId72"> > <TD width="150" id="digiId73"> > <FORM action="http://yahoo.com/" name="mfrm" > id="digiId74"> > <INPUT type="hidden" name="itag" value="ody" > id="digiId75"> > </TD> > <TD align="center" id="digiId76"> > <INPUT type="text" name="q" size="20" > maxlength="800" value="" style="width:319px" > id="digiId77"> > </TD> > <TD nowrap="" id="digiId78"> > <INPUT type="submit" value="FIND" > class="btn" id="digiId79"> > </TD> > </FORM> > </TABLE> > </TD> > </TR> > </HEAD> > </BODY> > </HTML> > > > > > > > ___________________________________________________________________________ > Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger > Téléchargez cette version sur http://fr.messenger.yahoo.com > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software Conference & EXPO > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf > _______________________________________________ > Htmlunit-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-user > |