Hi,

Ah.. I see that you dynamically generate the contents of the select box. I think this is where jwebunit/httpunit go wrong. I doubt they support such dynamic markup.

Martijn

Nilesh Trivedi wrote:

Hi all,

This is my source file, called "test.jsp":

<html>
<script language="JavaScript">
function getSelectHtml()
{
   var str="";
   str += "<option value=\"value1\">item1</option>";
   str += "<option value=\"value2\">item2</option>";
   return str;
}
</script>
<body>
<form id="form1">
    <select id="customer" name="customer">
        <script>document.write(getSelectHtml());</script>
    </select>
    <input type="submit" value="go" />
</form>
</body>
</html>


and here is my jwebunit testing code:

public class TestJS extends WebTestCase
{
    public TestJS(String name)
    {
        super(name);
    }
public void testNow() throws Exception
    {
        beginAt("test.jsp");
        setWorkingForm("form1");
        assertElementPresent("customer");
        setFormElement("customer","item1");
        return;
    }
}

I am getting the following exception on running the testcase:

com.meterware.httpunit.IllegalParameterValueException: May not set parameter 'customer' to 'item1'. Value must be one of: { } at com.meterware.httpunit.SelectionFormControl$Options.reportNoMatches(FormControl.java:1197) at com.meterware.httpunit.SelectionFormControl$SingleSelectOptions.claimUniqueValues(FormControl.java:1371) at com.meterware.httpunit.SelectionFormControl$Options.claimUniqueValues(FormControl.java:1189) at com.meterware.httpunit.SelectionFormControl.claimUniqueValue(FormControl.java:1070) 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)
at net.sourceforge.jwebunit.HttpUnitDialog.setFormParameter (HttpUnitDialog.java:299) at net.sourceforge.jwebunit.WebTester.setFormElement(WebTester.java:789) at net.sourceforge.jwebunit.WebTestCase.setFormElement(WebTestCase.java:317)
    at nuance.mserver.systemanalysis.TestJS.testNow (TestJS.java:18)
What I am not able to understand is that why is the array of allowed options is coming as empty "{ }" ??

Has anyone faced similar issues before ??
Thanks
Nilesh




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
Jwebunit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users

Reply via email to