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

Marc Guillemot webtest@lists.canoo.com
Tue, 03 Aug 2004 09:36:37 +0200


and what is with something like:

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

Marc.

Ji Kim wrote:
> 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="get" name="compareForm" action="/docompare.html"
> onsubmit="javascript:return(verify())" >
>   <input type="checkbox" name="id" value="1" />
>       <a href="/someitem1.html">some gzimo 1</a>
> 
>   <input type="checkbox" name="id" value="2" />
>       <a href="/someitem2.html">some gzimo 2</a> 
> ...
> 
> 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. 
> 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.
>>
>>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.
>>
>>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.
>>
>>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=com.canoo.webtest.steps.SetSelectField
>>setselectfield=com.canoo.webtest.steps.form.SetSelectField
>>
>>Property file
>>target.item=//input[@type="checkbox" and @name="id"]
>>
>>Checkboxtest.xml
>>
>>           <storexpath
>>                 stepid="get first checkbox value for comparison"
>>                 xpath="(${target.item})[1]/@value"
>>                 property="checkbox1.value"
>>             />
>>            <storexpath
>>                 stepid="get first checkbox name for comparison"
>>                 xpath="(${target.item})[1]/@name"
>>                 property="checkbox1.name"
>>            />
>>            <setselectfield
>>                 stepid="select first product for comparison"
>>                 name="#{checkbox1.name}"
>>                 value="#{checkbox1.value}"
>>                 multiselect="true"
>>            />
>>....
>>           <clicklink
>>                 stepid="click on the next page"
>>                 label=""
>>                 href="#{nextlink.href}"
>>            />
>>
>>            <storexpath
>>                 stepid="get second checkbox value for comparison"
>>                 xpath="(${target.item})[1]/@value"
>>                 property="checkbox2.value"
>>            />
>>
>>            <storexpath
>>                 stepid="get second heckbox name for comparison"
>>                 xpath="(${target.item})[1]/@name"
>>                 property="checkbox2.name"
>>            />
>>
>>            <old_setselectfield
>>                 stepid="select third product from another page"
>>                 name="#{checkbox2.name}"
>>                 value="#{checkbox2.value}"
>>                 multiselect="true"
>>            />
>>
>>          <clickbutton
>>               stepid="submit comparison"
>>               save="lastResponse"
>>               name="" >
>>               <form name="mainForm"  />
>>               <index value="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="true", value="30833389", stepId="select third product 
>>from another page", name="id", regex="false", 
>>stepType="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 
>>'30833389'.,
>>Step: SetSelectField at
>>file:C:/CVSROOT/webtest/smoketest/tests/reg-4502.xml:107:  with 
>>(multiselect="true", value="30833389", stepId="select third product 
>>from another page", name="id", regex="false", 
>>stepType="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 
>>>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.   
>>>
>>>This:
>>>
>>>List li = Arrays.asList(form.getParameterValues(getName()));
>>>li.add(strValue);
>>>form.setParameter(getName(), (String[]) li.toArray(new String[]{}));
>>>
>>>Should be something like this:
>>>
>>>ArrayList al = 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
>>
> 
> 
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest