[Webtest] Using setcheckbox

Richard Burgess webtest@lists.canoo.com
Tue, 26 Nov 2002 14:03:33 +0000


--pf9I7BMVVzbSWLtt
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

On Tue, Nov 26, 2002 at 10:56:32AM +0100, Carsten Seibert wrote:
> Hi Richard,
> 
> 1) You're right, this is currently not support. I'll add it asap, maybe
> already today, if I can find the time.

This behaviour is fixed in build 265.  Thanks.

> 2) + 3) I was not able to reproduce the behavior that you've described. I've
> created a functional test in selfTestImpl.xml in order to try and reproduce
> your problem, but it worked fine for me. Maybe you could have a look at it
> and check if it covers your scenarios properly. Please try the latest build
> and check if your problem still appears. If so, post the HTML page plus your
> test code to the list and I will have an even closer look at it, especially
> at your particular test scenario.

I have looked at the tests in selfTestImpl.xml and written a couple more
that fail.  These demonstrate the behaviour I am experiencing.

I have attached the diff of doc/samples/selfTestImpl.xml.

A quick glimpse through the source suggests the former could be
rectified with a small fix in SetCheckbox.java (diff attached).  The
latter looks like it will involve another Collection, eg.
fNextRemoveParameterValues, in Context.java to hold the list of values
to remove from the existing set of parameter values.

Thanks,
Richard.

> Thanks,
> Carsten
> 
> Carsten Seibert
> seiberTEC GmbH Switzerland
> mailto:seibert@seibertec.ch  / phone: +41 79 636 4317

-- 
astfgl@lost.net.au

This life is a test.  It is only a test.  Had this been an actual life, you
would have received further instructions as to what to do and where to go.

--pf9I7BMVVzbSWLtt
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="SetCheckbox.diff"

*** src/com/canoo/webtest/steps/SetCheckbox.java.OLD	2002-11-26 13:55:29.000000000 +0000
--- src/com/canoo/webtest/steps/SetCheckbox.java	2002-11-26 13:54:52.000000000 +0000
***************
*** 42,52 ****
          verifyParameters();
  
          if(fIsChecked) {
              if(fValue == null) {
!                 context.addParameterValue(new ParameterHolder(fCheckboxName, DEFAULT_VALUE));
              } else {
!                 context.addParameterValue(new ParameterHolder(fCheckboxName, fValue));
              }
          } else {
              context.addResetParameter(expandDynamicProperties(fCheckboxName));
          }
--- 42,55 ----
          verifyParameters();
  
          if(fIsChecked) {
+ 			ParameterHolder holder = null;
              if(fValue == null) {
!                 holder = new ParameterHolder(fCheckboxName, DEFAULT_VALUE);
              } else {
!                 holder = new ParameterHolder(fCheckboxName, fValue);
              }
+ 			holder.setPreserveExistingValue(true);
+ 			context.addParameterValue(holder);
          } else {
              context.addResetParameter(expandDynamicProperties(fCheckboxName));
          }

--pf9I7BMVVzbSWLtt
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="selfTestImpl.diff"

--- ../webtest.BAK/doc/samples/selfTestImpl.xml	2002-11-26 13:17:30.000000000 +0000
+++ doc/samples/selfTestImpl.xml	2002-11-26 13:46:26.000000000 +0000
@@ -1004,6 +1004,77 @@
                     value="check3"/>
 
                 <!--
+					Check checking additional checkboxes preserves already checked checkboxes of the same name
+                -->
+                <invoke
+                    save="debugTest"
+                    stepid="Check preservation of already checked checkboxes"
+					url="${start.page}?mode=checkboxTest&amp;c2=check2"/>
+                <verifycheckbox
+					stepid="Verify checkbox 'c2' with value 'check2' is initially checked"
+                    name="c2"
+                    checked="true"
+                    value="check2"/>
+                <verifycheckbox
+					stepid="Verify checkbox 'c2' with value 'check3' is initially unchecked"
+                    name="c2"
+                    checked="false"
+                    value="check3"/>
+                <setcheckbox
+					stepid="Check checkbox with value 'check3'"
+                    name="c2"
+                    value="check3"/>
+                <clickbutton
+                    stepid="submit the form to check preservation of already checked items"
+                    label="doIt"/>
+                <verifycheckbox
+					stepid="Verify checkbox 'c2' with value 'check2' remains checked"
+                    name="c2"
+                    checked="true"
+                    value="check2"/>
+                <verifycheckbox
+					stepid="Verify checkbox 'c2' with value 'check3' becomes checked"
+                    name="c2"
+                    checked="true"
+                    value="check3"/>
+
+                <!--
+					Check unchecking individual checkboxes with values leaves other checkboxes of same name checked.
+                -->
+                <invoke
+                    save="debugTest"
+                    stepid="Check preservation of already checked checkboxes"
+					url="${start.page}?mode=checkboxTest&amp;c2=check2&amp;c2=check3"/>
+                <verifycheckbox
+					stepid="Verify checkbox 'c2' with value 'check2' is initially checked"
+                    name="c2"
+                    checked="true"
+                    value="check2"/>
+                <verifycheckbox
+					stepid="Verify checkbox 'c2' with value 'check3' is initially checked"
+                    name="c2"
+                    checked="true"
+                    value="check3"/>
+                <setcheckbox
+					stepid="Uncheck checkbox with value 'check3'"
+                    name="c2"
+					value="check3"
+					checked="false"/>
+                <clickbutton
+                    stepid="submit the form to check preservation of already checked items"
+                    label="doIt"/>
+                <verifycheckbox
+					stepid="Verify checkbox 'c2' with value 'check2' remains checked"
+                    name="c2"
+                    checked="true"
+                    value="check2"/>
+                <verifycheckbox
+					stepid="Verify checkbox 'c2' with value 'check3' is now unchecked"
+                    name="c2"
+                    checked="false"
+                    value="check3"/>
+
+                <!--
                     Reset a checked checkbox
                 -->
                 <invoke

--pf9I7BMVVzbSWLtt--