Help about 'com.meterware.httpunit.Illega lParameterValueException'
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,
When I used HttpUnit1.6.2 for testing struts-cookbook-1.3.8.war, I got a exception of 'IllegalParameterValueException'.Details as follows:
public void testFistExecute() throws Exception
{
WebConversation wc = new WebConversation();
WebResponse response = wc.getResponse("<A href="http://127.0.0.1:8080/struts-cookbook-1.3.8/">http://127.0.0.1:8080/struts-cookbook-1.3.8/</A>");
WebLink link = response.getLinks()[1];
WebResponse newResp = link.click();
WebForm form = newResp.getFormWithID("simpleForm");
assertTrue(form.hasParameterNamed("color"));
form.setParameter("color", "blue");
}
// the stack trace
com.meterware.httpunit.IllegalParameterValueException: May not set parameter 'color' to 'blue'. Value must be one of: { }
at com.meterware.httpunit.SelectionFormControl$Options.reportNoMatches(FormControl.java:1186)
at com.meterware.httpunit.SelectionFormControl$SingleSelectOptions.claimUniqueValues(FormControl.java:1360)
at com.meterware.httpunit.SelectionFormControl$Options.claimUniqueValues(FormControl.java:1178)
at com.meterware.httpunit.SelectionFormControl.claimUniqueValue(FormControl.java:1059)
at com.meterware.httpunit.FormParameter.setValues(FormParameter.java:90)
at com.meterware.httpunit.WebForm.setParameter(WebForm.java:612)
at com.meterware.httpunit.WebForm.setParameter(WebForm.java:601)
...
// the Simple.jsp
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<A href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</A>">
<%@ page language="java" contentType="text/html; charset=utf-8" %>
<%@ taglib uri="<A href="http://struts.apache.org/tags-bean">http://struts.apache.org/tags-bean</A>" prefix="bean" %>
<%@ taglib uri="<A href="http://struts.apache.org/tags-html">http://struts.apache.org/tags-html</A>" prefix="html" %>
<html:html xhtml="true" lang="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Simple form using ActionForm</title>
<html:base/>
<link rel="stylesheet" type="text/css" href="../../css/example.css" />
</head>
<body>
<html:link page="/jsp/simple/source.jsp">
<img src="../../images/code.gif" width="24" height="24" alt="View Source" class="icon" />
</html:link>
<a href="../../index.jsp"><img src="../../images/return.gif" height="24" width="24" alt="Return to examples page" class="icon" /></a>
<h1>Simple form using ActionForm</h1>
<hr noshade="noshade"/>
<p>Enter information into the fields below. Your entries will be displayed when you Submit the form.<br />
This is just to demonstrate the Struts html tags. The information that you enter is discarded.</p>
<p>* = required field</p>
<hr noshade="noshade" />
<html:errors/>
<html:form action="/processSimple">
<p>* What's your first name?:<br/><html:text property="name" size="40" maxlength="50"/></p>
<p>* Enter a secret word or phrase:<br/><html:password property="secret" size="40" maxlength="50"/></p>
<p>What is your favorite color?:<br/>
<html:select property="color">
<html:option value="red">Red</html:option>
<html:option value="green">Green</html:option>
<html:option value="blue">Blue</html:option>
</html:select>
</p>
<p><html:checkbox property="confirm"/>Is that really your favorite color?</p>
<p>How much do you like your chosen color?:<br />
<html:radio property="rating" value="1">Actually, I hate it.</html:radio><br />
<html:radio property="rating" value="2">Not so much.</html:radio><br />
<html:radio property="rating" value="3">I'm indifferent</html:radio><br />
<html:radio property="rating" value="4">It's pretty neat</html:radio><br />
<html:radio property="rating" value="5">I painted my whole house with it.</html:radio>
</p>
<p>Enter a message (you may use html tags):<br />
<html:textarea property="message" cols="40" rows="6"/>
</p>
<html:hidden property="hidden" value="Sssh! It's a secret. Nobody knows I'm here."/>
<hr noshade="noshade" />
<p>
<html:submit>
<bean:message key="button.submit" />
</html:submit>
<html:cancel/>
</p>
</html:form>
</body>
</html:html>
Thanks.
Jin Jiankang
一 起 来,150 万 人 同 时 在 玩 的 梦 幻 西 游
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop