From: James A. <the...@ya...> - 2003-08-06 18:06:49
|
After playing with this some more, I came up with a much simpler test to make sure I was doing things correctly, yet I still get the same errors, actually I seem to have gotten more. Here is the html I'm testing: <html> <body> <form name="test" id="test" method="post"> <input name="inputBox" type="text"> <input name="submitButton" type="submit" value="submit it"> </form> </body> </html> Here is the test I have: public void testHomePage() throws Exception { /* used for JSSE */ System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); final WebClient webClient = new WebClient(); webClient.setJavaScriptEnabled(false); webClient.setRedirectEnabled(true); final URL url = new URL("https://www.ksu.edu/test/james/formTest.html"); HtmlPage page1 = (HtmlPage)webClient.getPage(url); writeToFile(page1); /* used to save the returned hmtml */ List l = page1.getAllForms(); final HtmlForm form = (HtmlForm)l.get(l.size() -1); HtmlInput ip = null; /* getAllInputsByName("") shouldn't have "", it should be "test", but that doesn't work */ ArrayList al = new ArrayList(form.getAllInputsByName("")); for(int i = 0; i < al.size(); i++) { ip = (HtmlInput)al.get(i); System.out.println("|"+ip.getNameAttribute()+"|"); System.out.println("|"+ip.getTypeAttribute()+"|"); System.out.println("|"+ip.getValueAttribute()+"|"); System.out.println("|"+ip.toString()+"|"); } System.out.println(al.size()); } And that returns this: [junit] ------------- Standard Output --------------- [junit] || [junit] || [junit] || [junit] |HtmlTextInput[<input name="inputBox" type="text">]| [junit] || [junit] || [junit] || [junit] |HtmlTextInput[<input name="submitButton" type="submit" value="submit it">]| [junit] 2 [junit] ------------- ---------------- --------------- So something is wrong here, either HtmlUnit isn't working right, or I'm doing something wrong, but either way, I don't know what to do to fix it. Thank you. --- James Asher <the...@ya...> wrote: > I am having problems getting certain form elements. > I > can't get HtmlForm or HtmlInput by the name > attribute. > If I do something like this: > > final HtmlForm form = (HtmlForm)l.get(l.size() -1); > HtmlInput ip = null; > ArrayList al = new > ArrayList(form.getAllSubmittableElements()); > for(int i = 0; i < al.size(); i++) { > ip = (HtmlInput)al.get(i); > > System.out.println("|"+ip.getNameAttribute()+"|"); > } > > I get output like this: > || > || > || > > The form I'm trying to get and eventually submit > looks > like this: > <form name="signonForm" method="POST" > action="/keas/profile/signon.do;jsessionid=3D51678DB56D4A16C867DA7DEBA"> > > <table border="0" cellspacing="10" cellpadding="0" > width="60%" summary=""> > <tr><td rowspan="5" width="20%"> </td> > <td colspan="2" align="left"></td></tr> > <tr><td width="30%"><span class="title" > style="color:#333333;"><label > for="eid">eID</label></span></td> > <td width="50%" align="right"><input type="text" > name="eid" maxlength="50" size="22" value="" > class="plain"></td></tr> > <tr><td colspan="2" align="left"></td></tr> > <tr><td width="30%"><span class="title" > style="color:#333333;"><label > for="passwd">password</label></span></td> > <td width="50%" align="right"><input > type="password" name="password" maxlength="50" > size="22" value="" class="plain"></td></tr> > <tr><td colspan="2" align="right"><input > type="image" > name="" > src="/keas/images/signin-button.gif;jsessionid=3D59178DB56DA16C81867DEBAE9" > alt="Sign in" border="0"></td></tr> > </table> > </form> > > They all have name attributes, so what's the deal? > > I had this problem in 1.2.2 as well as 1.2.3 > > > Thuroughly perplexed, > - Asher. > > __________________________________ > Do you Yahoo!? > Yahoo! SiteBuilder - Free, easy-to-use web site > design software > http://sitebuilder.yahoo.com > > > ------------------------------------------------------- > This SF.Net email sponsored by: Free pre-built > ASP.NET sites including > Data Reports, E-commerce, Portals, and Forums are > available now. > Download today and enter to win an XBOX or Visual > Studio .NET. > http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01 > _______________________________________________ > HtmlUnit-develop mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlunit-develop __________________________________ Do you Yahoo!? Yahoo! SiteBuilder - Free, easy-to-use web site design software http://sitebuilder.yahoo.com |