#395 Accessing Options in a form is in lower case


A webpage has a form including 'select' and 'option' tags.

When setting a parameter like
form.setParameter("param", "value");
it does not work if the websites defines a Namespace URI:
<html xmlns="http://www.w3.org/1999/xhtml">.

In this case, a com.meterware.httpunit.FormParameter$UnusedParameterValueException
will be thrown.

I analyzed the problem:
The class com.meterware.httpunit.FormControl
retrieves a list of Options from
the selection node (line 1162):

NodeList nl = ((Element) selectionNode).getElementsByTagName( "option" );

Note: the NodeList is requested in lower case, but the
org.w3c.dom.Node contains the child options in upper

If the Namespace URI is not defined, the cases are
ignored. But if the Namespace URI is define, the
Node takes care for the cases.
This means: When requesting the Elements by tag name "option", Node returns an empty list.

This causes HTTPUnit not to be able to set a Parameter value and the exception is thrown.

I tested it in upper cases and it works fine:
NodeList nl = ((Element) selectionNode).getElementsByTagName( "OPTION" );


  • Wolfgang Fahl

    Wolfgang Fahl - 2007-12-30

    Logged In: YES
    Originator: NO

    Thank you for your comment:

    I tried this with the following test Case:
    * check that an UnusedParameterValueException is not
    * thrown if a parameter value is not supplied
    * @throws Exception
    public void testBug1843978() throws Exception {
    defineWebPage( "http://www.w3.org/1999/xhtml", "Default", "<form method=GET action = '/ask'>" +
    "<Select name=colors><Option>blue<Option>red</Select>" +
    "<Input type=submit></form>" );
    WebResponse page = _wc.getResponse( getHostPath() + "/Default.html" );
    WebRequest request = page.getForms()[0].getRequest();
    try {
    request.setParameter( "colors", "blue" );
    } catch (FormParameter.UnusedParameterValueException e) {
    fail( "Should not have rejected set of unused parameter value" );

    unfortunately it does not catch the problem ... could you please help in creating a test case that catches
    what you observed?

    could you please get the latest version from svn and check this yourself?

  • Wolfgang Fahl

    Wolfgang Fahl - 2007-12-30
    • assigned_to: nobody --> wolfgang_fahl
    • status: open --> pending
  • Wolfgang Fahl

    Wolfgang Fahl - 2007-12-30
    • status: pending --> closed
  • Wolfgang Fahl

    Wolfgang Fahl - 2007-12-30

    Logged In: YES
    Originator: NO

    The uppercase version does not break any tests so i changed it.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks