From: Vijay N. <VNa...@ma...> - 2003-12-17 21:58:46
|
Danny, I tried the getOption(int i) method. It gave me "no such method exception " I am able to get a List of Options by calling getAllOptions(); Since none of these options have a "VALUE" selecting the option fails and also the getValueAttribute() The following is the code snippet I use and the error I got //CODE SNIPPET final HtmlSelect max = (HtmlSelect)form.getSelectByName("MAXDOCS"); List maxopts=max.getAllOptions(); System.out.println(maxopts.size()); for(int i=0; i<maxopts.size(); i++){ System.out.println(maxopts.get(i)); } HtmlOption maxopt=(HtmlOption)maxopts.get(1); maxopt.setSelected(true); System.out.println("CHOICEMAX : "+maxopt.getValueAttribute()); //ERROR MESSAGE 5 HtmlOption[<option>] HtmlOption[<option selected="">] HtmlOption[<option>] HtmlOption[<option>] HtmlOption[<option>] java.lang.IllegalStateException: Can't select this option because it has no value set java.lang.IllegalStateException: Can't select this option because it has no value set at com.gargoylesoftware.htmlunit.html.HtmlOption.setSelected(HtmlOption.java:82 ) at AccessBioHtml.testHomePage(AccessBioHtml.java:102) at AccessBioHtml.main(AccessBioHtml.java:229) Vijay -----Original Message----- From: Danny Yoo [mailto:dy...@ac...] Sent: Wednesday, December 17, 2003 2:00 PM To: Vijay Narayanasamy Cc: 'htm...@li...' Subject: Re: Help with Options On Dec 17, 2003, at 9:28 AM, Vijay Narayanasamy wrote: > I am having difficulties using HtmlSelect for simulating the following > dropdown menu. Hi Vijay, There's a method called getOption(int i) that looks like it should do the trick. Or you can run through all the options with getAllOptions(), and choose the right one by looking at each option's getValueAttribute(), I think. > The Options have no Value. > > <SELECT NAME="MAXDOCS"> > > <OPTION >25 > > <OPTION SELECTED>50 > > <OPTION >100 > > <OPTION >250 > > <OPTION >500 > > </SELECT> From what I understand, the value of each option should default to the text content. So you should see those four options, and each com.gargoylesoftware.htmlunit.html.HtmlOption should have a getValueAttribute(). Good luck to you! |