首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

使用HttpUnit时,怎么向select控件赋值

2012-01-22 
使用HttpUnit时,如何向select控件赋值?假设某JSP中有select控件如下:selectname color optionvalue

使用HttpUnit时,如何向select控件赋值?
假设某JSP中有select控件如下:
<select   name= "color ">
    <option   value= "red "> Red </option>
    <option   value= "green "> Green </option>
    <option   value= "blue "> Blue </option>
</select>

我通过form.setParameter( "color ",   "green ");赋值,却提示:
com.meterware.httpunit.IllegalParameterValueException:   May   not   set   parameter   'color '   to   'blue '.   Value   must   be   one   of:   {     }

请同道指点,谢谢!

        public   void   testExecute1()   throws   Exception
        {
WebConversation   wc   =   new   WebConversation();
WebRequest   request   =   new   GetMethodWebRequest( "http://127.0.0.1:8088/struts-cookbook-1.3.8/ ");
WebResponse   response   =   wc.getResponse(request);
WebLink   link   =   response.getLinkWith( "Execute ");
assertNotNull( "superLink   'Execute '   is   null ",   link);

WebResponse   responseOfExecute   =   link.click();
WebForm   form   =   responseOfExecute.getFormWithID( "simpleForm ");
assertNotNull( "form   'simpleForm '   is   null ",   form);
               
    assertTrue( "no   parameter   named   'color ' ",   form.hasParameterNamed( "color "));              
    form.setParameter( "color ",   "green ");   //   throws   exception
        }

[解决办法]
给select赋值?????

热点排行