[Webtest] Re: array of values for <setcheckbox>

Ji Kim webtest@lists.canoo.com
Tue, 3 Aug 2004 09:05:54 -0700


The parameter "id" is set to "2" REPLACING the old value of "1" where as
if I use setselectfield with multivalue set to true lets me set it to
both "1" and "2".=20

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

and what is with something like:

<new_setcheckbox checked=3D"true" name=3D"id" value=3D"1"/> =
<new_setcheckbox
checked=3D"true" name=3D"id" value=3D"2"/>

Marc.

Ji Kim wrote:
> No, I am not trying to write a test case a user can't perform with a=20
> web browser. The html page I have to deal with is something like this
>=20
> <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>
>=20
>   <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=20
> result in a form that has multiple instances of the parameter "id"=20
> wich different values.
>=20
> -----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>
>=20
> If i correctly understand it, you want to give the checkbox a value=20
> different of the one that is contained in the html.
> That is to do something that would not be possible when surfing on the

> page with a browser. Right?
>=20
> 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=20
> anything and make it more difficult to understand for people not aware

> of your test's internals.
>=20
> Marc.
>=20
> Ji Kim wrote:
>=20
>>Thank you both for the response.
>>
>>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.
>>
>>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.
>>
>>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
>=20
> selected.
>=20
>>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.
>>
>>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=20
>><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=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.StepExecutionExcep=
t
>>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",
>>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=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
>=20
>=20
>>bring you problems when a better check will be performed. Later when=20
>>we will move to htmlunit.
>>
>> > However there is a BUG in
>>
>>
>>>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[]{}));
>>
>>
>>ok. Have you a webtest for this bug?
>>
>>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
>=20
> _______________________________________________
> 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