[Webtest] array of values for <setcheckbox>

Ji Kim webtest@lists.canoo.com
Mon, 2 Aug 2004 11:19:39 -0700


No, I am not trying to write a test case a user can't perform with a web
browser. The html page I have to deal with is something like this

<form method=3D"get" name=3D"compareForm" action=3D"/docompare.html"
onsubmit=3D"javascript:return(verify())" >
  <input type=3D"checkbox" name=3D"id" value=3D"1" />
      <a href=3D"/someitem1.html">some gzimo 1</a>

  <input type=3D"checkbox" name=3D"id" value=3D"2" />
      <a href=3D"/someitem2.html">some gzimo 2</a>=20
...

The user surfing the web can and does check more than one boxes which
result in a form that has multiple instances of the parameter "id" wich
different values.

-----Original Message-----
From: webtest-admin@gate2.canoo.com
[mailto:webtest-admin@gate2.canoo.com] On Behalf Of Marc Guillemot
Sent: Monday, August 02, 2004 12:03 AM
To: webtest@gate2.canoo.com
Subject: Re: [Webtest] array of values for <setcheckbox>

If i correctly understand it, you want to give the checkbox a value
different of the one that is contained in the html.=20
That is to do something that would not be possible when surfing on the
page with a browser. Right?

Btw: when you sent an example, please make it as small as possible. In
this case, the xpath expressions and dynamic properties don't bring
anything and make it more difficult to understand for people not aware
of your test's internals.

Marc.

Ji Kim wrote:
> Thank you both for the response.
>=20
> The new_setcheckbox as with the older version, I can only specify ONE=20
> value when I need to select multiple checkboxes. I need to test an=20
> html page that lists multiple items all  having a checkbox with the=20
> same name but each with different value.
>=20
> Louis, thanks very much for the help. I was able to use=20
> <new_setselectfield> after applying the fix you suggested. I would=20
> prefer to use <new_setcheckbox> as long as there is a way to specify=20
> multiple values.
>=20
> I did run into another problem. After I select multiple checkboxes=20
> with the same name but different values, I click on Javascript link=20
> that leads to more items while retaining the parameters previously
selected.
> When I try to select more checkboxes again with the same name but=20
> different values, <new_setselectfield> wouldn't let me but the older=20
> version would.
>=20
> old_setselectfield=3Dcom.canoo.webtest.steps.SetSelectField
> setselectfield=3Dcom.canoo.webtest.steps.form.SetSelectField
>=20
> Property file
> target.item=3D//input[@type=3D"checkbox" and @name=3D"id"]
>=20
> Checkboxtest.xml
>=20
>            <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}"
>             />
>=20
>             <storexpath
>                  stepid=3D"get second checkbox value for comparison"
>                  xpath=3D"(${target.item})[1]/@value"
>                  property=3D"checkbox2.value"
>             />
>=20
>             <storexpath
>                  stepid=3D"get second heckbox name for comparison"
>                  xpath=3D"(${target.item})[1]/@name"
>                  property=3D"checkbox2.name"
>             />
>=20
>             <old_setselectfield
>                  stepid=3D"select third product from another page"
>                  name=3D"#{checkbox2.name}"
>                  value=3D"#{checkbox2.value}"
>                  multiselect=3D"true"
>             />
>=20
>           <clickbutton
>                stepid=3D"submit comparison"
>                save=3D"lastResponse"
>                name=3D"" >
>                <form name=3D"mainForm"  />
>                <index value=3D"1"   />
>            </clickbutton>
>=20
> This works with the old <setselectfield>, When I use the=20
> <new_setselectfield>, it comes with the following error.
>=20
> Exception raised: com.canoo.webtest.engine.StepExecutionException:
> Unexpected exception caught:
> com.meterware.httpunit.FormParameter$UnusedParameterValueException:
> Attempted to assign to parameter 'id' the extraneous value=20
> '30833389'.,
> Step: SetSelectField at
> file:C:/CVSROOT/webtest/smoketest/tests/reg-4502.xml:107:  with=20
> (multiselect=3D"true", value=3D"30833389", stepId=3D"select third =
product=20
> from another page", name=3D"id", regex=3D"false",=20
> =
stepType=3D"setselectfield")com.canoo.webtest.engine.StepExecutionExcept
> io
> n: Unexpected exception caught:
> com.meterware.httpunit.FormParameter$UnusedParameterValueException:
> Attempted to assign to parameter 'id' the extraneous value=20
> '30833389'.,
> Step: SetSelectField at
> file:C:/CVSROOT/webtest/smoketest/tests/reg-4502.xml:107:  with=20
> (multiselect=3D"true", value=3D"30833389", stepId=3D"select third =
product=20
> from another page", name=3D"id", regex=3D"false",=20
> stepType=3D"setselectfield")
>=20
> -----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>
>=20
>>Check boxes with multiple set return data exactly the same way as=20
>>select lists do.  So I use the new_setselectfield tag.
>=20
>=20
> why doesn't new_setcheckbox work? Giving the value attribute, you can=20
> specify which check box you want to (un)check when many checkboxes=20
> 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=20
> we will move to htmlunit.
>=20
>  > However there is a BUG in
>=20
>>the code there.  =20
>>
>>This:
>>
>>List li =3D Arrays.asList(form.getParameterValues(getName()));
>>li.add(strValue);
>>form.setParameter(getName(), (String[]) li.toArray(new String[]{}));
>>
>>Should be something like this:
>>
>>ArrayList al =3D new
>>ArrayList(Arrays.asList(form.getParameterValues(getName())));
>>al.add(strValue);
>>form.setParameter(getName(), (String[]) al.toArray(new String[]{}));
>=20
>=20
> ok. Have you a webtest for this bug?
>=20
> Marc.
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>=20

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