Hello Sandro, thanks for the suggestion, but no luck either, unfortunately.
I have now had a look at the source code of the repeat step. From my limited point of view, I think the problem is that the counter _is not_ stored as a webtest property if the loop is using an XPath expression. So far, I have not found any way to retrieve the current node. Maybe I should open a JIRA ticket? Regards Beat ---- [email protected] schrieb: > > Hi Beat, > > maybe this could work: > > the repeat step places the counterName-Value in a webtest property, not a > groovy variable, which can't be accessed using $propertyName. > Groovy tries to evaluate $propertyName as a groovy variable, which will > fail. > > Try "\${propertyName}" to access the webtest-property(-> Ant). > But be carefull, the expression "\${propertyName}" is only evaluated inside > a webtest-step like verfiyXPath. The following won't work: > > def varName = "\${webTestProperty}" > > The result will exactly be the string, but not the property's value :) > > Regards, > Sandro > > > > > > Beat Koch > <[email protected] > > To > Sent by: [email protected] > webtest-ad...@gat cc > e4.canoo.com > 15.06.2009 00:34 Subject > [Webtest] RE: Repeat step in a > Groovy test case > Please respond to > [email protected] > oo.com > > > > > > > > I've done some tests (i.e. dozens of trial and error runs)... The following > Webtest ant script works perfectly: > > --- > <?xml version="1.0"?> > <!DOCTYPE project SYSTEM "../dtd/Project.dtd"> > <project default="test"> > <target name="test"> > <webtest name="Check repeat step"> > <invoke url="http://localhost/~bkoch/cbt.html"/> > <repeat xpath="//inp...@type='checkbox']" counterName="currentButton"> > <verifyCheckbox xpath="$currentButton" checked="false"/> > </repeat> > <repeat xpath="//inp...@type='radio']" counterName="rb"> > <verifyRadioButton xpath="$rb" checked="false"/> > </repeat> > <repeat count="3"> > <testInfo type="Debug" info="Hello world: #{count}" /> > </repeat> > </webtest> > </target> > </project> > --- > > However, the following Webtest Groovy class can not be executed: > > --- > import com.canoo.webtest.WebtestCase > > class SimpleTest extends WebtestCase { > void testWebtestOnGoogle() { > webtest("Check repeat step") { > invoke "http://localhost/~bkoch/cbt.html" > repeat (xpath:"//inp...@type='checkbox']", > counterName:"currentButton") { > verifyCheckbox xpath:"$currentButton", checked:"false" > } > repeat (xpath:"//inp...@type='radio']", counterName:"rb") { > verifyRadioButton xpath:"$rb", checked:"false" > } > repeat (count:"3") { > testInfo type:"Debug", info:"Hello world: #{count}" > } > } > } > } > --- > > The error is: > 1) testWebtestOnGoogle(SimpleTest)groovy.lang.MissingPropertyException: No > such property: currentButton for class: SimpleTest > at > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:49) > at > org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49) > at > org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:240) > at > SimpleTest$_testWebtestOnGoogle_closure1_closure2.doCall(repeatTest.groovy:8) > > Line 8 is the verifyCheckbox one. If I comment it out, then the error > appears on the verifyRadioButton line. Strangely enough, the testInfo line > executes fine. As a consequence, I have tried to use #{currentButton} > instead of $currentButton on the verifyCheckbox line but then I get the > following error during execution: > > com.canoo.webtest.engine.StepExecutionException > > Stacktrace > > : Error processing xpath "#{currentButton}"., Step: VerifyCheckbox at : > with (taskName="verifyCheckbox") > > I believe that the ant script and Groovy class are identical from a > semantical point of view. Either I'm wrong about this (and I would > appreciate any pointer to the correct Groovy implementation) or there > really is a problem with Webtest. > > Regards > Beat > > > PS: This is my test page: > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" " > http://www.w3.org/TR/html4/strict.dtd"> > <html> > <head> > <title>Checkbox test page</title> > </head> > <body> > <form name="CBT"> > <p><input type="checkbox" id="cb1"/></p> > <p><input type="checkbox" id="cb2"/></p> > <p><input type="checkbox" id="cb3"/></p> > > <p><input type="radio" id="rb1" name="group1"/></p> > <p><input type="radio" id="rb2" name="group1"/></p> > <p><input type="radio" id="rb3" name="group1"/></p> > </form> > </body> > </html> > > > > PricewaterhouseCoopers Aktiengesellschaft Wirtschaftsprüfungsgesellschaft > > Vorsitzender des Aufsichtsrates > WP StB Reiner Dickmann > > Vorstandsmitglieder > WP StB Hans Wagener · WP StB Peter Albrecht · WP StB Frank Brebeck · StB > Prof. Dr. Dieter Endres > WP StB Ernst-Wilhelm Frings · WP RA Dr. Hans Friedrich Gelhausen · WP StB > Werner Hölzl > WP StB Prof. Dr. Georg Kämpfer · WP RA StB Dr. Jan Konerding · WP StB Georg > Kütter · Dr. Ludger Mansfeld > StB Marius Möller · WP StB Franz Nienborg · WP StB Gert-Michael Raabe > WP StB Martin Scholich · RA StB Christoph Schreiber · WP StB Dr. Norbert > Vogelpoth > WP StB Franz Wagner · WP StB Wolfgang Wagner · WP StB Prof. Dr. Norbert > Winkeljohann > > Sitz: Frankfurt am Main - Amtsgericht Frankfurt am Main HRB 44845 > > Mitglied von PricewaterhouseCoopers International, einer Company limited by > guarantee registriert in England und Wales > _________________________________________________________________ > Diese Information ist ausschliesslich fuer den Adressaten bestimmt und kann > vertraulich oder gesetzlich geschuetzte Informationen enthalten. Wenn Sie > nicht der bestimmungsgemaesse Adressat sind, unterrichten Sie bitte den > Absender und vernichten Sie diese Mail. Anderen als dem > bestimmungsgemaessen Adressaten ist es untersagt, diese E-Mail zu lesen, zu > speichern, weiterzuleiten oder ihren Inhalt auf welche Weise auch immer zu > verwenden. Wir verwenden aktuelle Virenschutzprogramme. Fuer Schaeden, die > dem Empfaenger gleichwohl durch von uns zugesandte mit Viren befallene > E-Mails entstehen, schliessen wir jede Haftung aus. > > * * * * * > > The information contained in this email is intended only for its addressee > and may contain confidential and/or privileged information. If the reader > of this email is not the intended recipient, you are hereby notified that > reading, saving, distribution or use of the content of this email in any > way is prohibited. If you have received this email in error, please notify > the sender and delete the email. We use updated antivirus protection > software. We do not accept any responsibility for damages caused anyhow by > viruses transmitted via email. _______________________________________________ WebTest mailing list [email protected] http://lists.canoo.com/mailman/listinfo/webtest

