[Webtest] A problem with <clickbutton...> used with image buttons

webtest@lists.canoo.com webtest@lists.canoo.com
Thu, 25 Apr 2002 14:57:00 -0600


Hi,

I am using WebTest to check HTML that uses

    <form method="POST" action=...>
        ....
        <input type="image" name="myButton" src=...>
    </form>

And a WebTest step

    <clickbutton stepid="click image button" name="myButton" x="0" y="0"/>

NOTE: the x and y attributes are not specified in syntax.html, but are
supported by ClickButton.

The form is submitted with all the appropriate parameters *except* the X and
Y values (for
the HTML snippet above there should be two additional parameters:
myButton.x and
myButton.y).

What seems to be happening is:

If HttpUnitOptions.getParameterValuesValidated() is true (which seems to be
the default),
then the WebRequest constructed by ButtonByXxx.locateRequest() uses WebForm
as
the ParameterHolder.  The problem: WebForm.selectImageButtonPosition() only
sets the
button location with SubmitButton.setLocation() and does not generate the
".x" and ".y"
parameters. The result is these parameters are missing from the POST

However, if HttpUnitOptions.getParameterValuesValidated() is false, then the
WebRequest is
constructed using new UncheckedParameterHolder( WebForm) as the
ParameterHolder (see
WebRequest.newParameterHolder() ).
UncheckedParameterHolder.selectImageButtonPosition()
adds the ".x" and ".y" parameters to the request.

I have verified that my tests work as expected (e.g. include the ".x" and
".y" parameters
are included) by modifying ClickButton.doExecute() to

    protected void doExecute(TestContext context) throws Exception {
        boolean oldValue = HttpUnitOptions.getParameterValuesValidated();
                HttpUnitOptions.getParameterValuesValidated( false );

                /* the original contents of doExecute() go here */

                HttpUnitOptions.getParameterValuesValidated( oldValue );
    }

HttpUnitOptions.getParameterValuesValidated() enables / disables an error
check for
parameter values that cannot be set via the browser -- hence turning this
off is not a great
solution.

Does anyone have another way to solve this problem?

Thank you.

Stephen