[Webtest] array of values for <setcheckbox>

Ji Kim webtest@lists.canoo.com
Fri, 30 Jul 2004 12:20:48 -0700


Thank you both for the response.

The new_setcheckbox as with the older version, I can only specify ONE
value when I need to select multiple checkboxes. I need to test an html
page that lists multiple items all  having a checkbox with the same name
but each with different value.=20

Louis, thanks very much for the help. I was able to use
<new_setselectfield> after applying the fix you suggested. I would
prefer to use <new_setcheckbox> as long as there is a way to specify
multiple values.=20

I did run into another problem. After I select multiple checkboxes with
the same name but different values, I click on Javascript link that
leads to more items while retaining the parameters previously selected.
When I try to select more checkboxes again with the same name but
different values, <new_setselectfield> wouldn't let me but the older
version would.

old_setselectfield=3Dcom.canoo.webtest.steps.SetSelectField
setselectfield=3Dcom.canoo.webtest.steps.form.SetSelectField

Property file
target.item=3D//input[@type=3D"checkbox" and @name=3D"id"]

Checkboxtest.xml

           <storexpath
                 stepid=3D"get first checkbox value for comparison"
                 xpath=3D"(${target.item})[1]/@value"
                 property=3D"checkbox1.value"
             />
            <storexpath
                 stepid=3D"get first checkbox name for comparison"
                 xpath=3D"(${target.item})[1]/@name"
                 property=3D"checkbox1.name"
            />
            <setselectfield
                 stepid=3D"select first product for comparison"
                 name=3D"#{checkbox1.name}"
                 value=3D"#{checkbox1.value}"
                 multiselect=3D"true"
            />
....
           <clicklink
                 stepid=3D"click on the next page"
                 label=3D""
                 href=3D"#{nextlink.href}"
            />

            <storexpath
                 stepid=3D"get second checkbox value for comparison"
                 xpath=3D"(${target.item})[1]/@value"
                 property=3D"checkbox2.value"
            />

            <storexpath
                 stepid=3D"get second heckbox name for comparison"
                 xpath=3D"(${target.item})[1]/@name"
                 property=3D"checkbox2.name"
            />

            <old_setselectfield
                 stepid=3D"select third product from another page"
                 name=3D"#{checkbox2.name}"
                 value=3D"#{checkbox2.value}"
                 multiselect=3D"true"
            />

          <clickbutton
               stepid=3D"submit comparison"
               save=3D"lastResponse"
               name=3D"" >
               <form name=3D"mainForm"  />
               <index value=3D"1"   />
           </clickbutton>

This works with the old <setselectfield>, When I use the
<new_setselectfield>, it comes with the following error.

Exception raised: com.canoo.webtest.engine.StepExecutionException:
Unexpected exception caught:
com.meterware.httpunit.FormParameter$UnusedParameterValueException:
Attempted to assign to parameter 'id' the extraneous value '30833389'.,
Step: SetSelectField at
file:C:/CVSROOT/webtest/smoketest/tests/reg-4502.xml:107:  with
(multiselect=3D"true", value=3D"30833389", stepId=3D"select third =
product from
another page", name=3D"id", regex=3D"false",
stepType=3D"setselectfield")com.canoo.webtest.engine.StepExecutionExcepti=
o
n: Unexpected exception caught:
com.meterware.httpunit.FormParameter$UnusedParameterValueException:
Attempted to assign to parameter 'id' the extraneous value '30833389'.,
Step: SetSelectField at
file:C:/CVSROOT/webtest/smoketest/tests/reg-4502.xml:107:  with
(multiselect=3D"true", value=3D"30833389", stepId=3D"select third =
product from
another page", name=3D"id", regex=3D"false", =
stepType=3D"setselectfield")

-----Original Message-----
From: webtest-admin@gate2.canoo.com
[mailto:webtest-admin@gate2.canoo.com] On Behalf Of Marc Guillemot
Sent: Friday, July 30, 2004 2:14 AM
To: webtest@gate2.canoo.com
Subject: Re: [Webtest] array of values for <setcheckbox>

> Check boxes with multiple set return data exactly the same way as=20
> select lists do.  So I use the new_setselectfield tag.

why doesn't new_setcheckbox work? Giving the value attribute, you can
specify which check box you want to (un)check when many checkboxes have
the same name.
Using "new_setselectfield" to set something else as select fields will
bring you problems when a better check will be performed. Later when we
will move to htmlunit.

 > However there is a BUG in
> the code there.  =20
>=20
> This:
>=20
> List li =3D Arrays.asList(form.getParameterValues(getName()));
> li.add(strValue);
> form.setParameter(getName(), (String[]) li.toArray(new String[]{}));
>=20
> Should be something like this:
>=20
> ArrayList al =3D new
> ArrayList(Arrays.asList(form.getParameterValues(getName())));
> al.add(strValue);
> form.setParameter(getName(), (String[]) al.toArray(new String[]{}));

ok. Have you a webtest for this bug?

Marc.
_______________________________________________
WebTest mailing list
WebTest@lists.canoo.com
http://lists.canoo.com/mailman/listinfo/webtest