Repeat step in a Groovy test case

View: New views
7 Messages — Rating Filter:   Alert me  

Repeat step in a Groovy test case

by Beat Koch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I have a Groovy class that extends WebtestCase. I'm trying to write a  
method checkResetState() that checks if all input elements on the  
current page are reset (check boxes and radio buttons not checked;  
text fields empty). This is what I have done for radio buttons:

def checkResetState() {
   ant.repeat(xpath:"//input[@type='radio']", counterName:"rb") {
     ant.groovy {
       def button = step.webtestProperties.rb
       println button  // For debugging purposes

       ant.verifyRadioButton xpath:"$button", checked:false
     }
   }
}

The ant.repeat part is ok; if I have three radio buttons on the page,  
then the closure is called three times. However, rb is not set and  
therefore; button is always null. As an alternative, I've tried

   ant.repeat(xpath:"//input[@type='radio']/@id", counterName:"rb") {

to just get the id's of the buttons, or just

   ant.repeat(xpath:"//input[@type='radio']/@id") {

and trying to use the count property, but no luck either. I haven't  
figured out how to access the "current counter value". Can anyone help  
me out?

Regards
Beat

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

Parent Message unknown RE: Repeat step in a Groovy test case

by Beat Koch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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">
 <repeat xpath="//input[@type='checkbox']" counterName="currentButton">
   <verifyCheckbox xpath="$currentButton" checked="false"/>
 </repeat>
 <repeat xpath="//input[@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") {
      repeat (xpath:"//input[@type='checkbox']", counterName:"currentButton") { 
        verifyCheckbox xpath:"$currentButton", checked:"false" 
      }
      repeat (xpath:"//input[@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>


Re: RE: Repeat step in a Groovy test case

by AcO6 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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


Inactive hide details for Beat Koch <bidli@hispeed.ch>Beat Koch <bidli@...>



To

webtest@...

cc


Subject

[Webtest] RE: Repeat step in a Groovy test case

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="//input[@type='checkbox']" counterName="currentButton">
<verifyCheckbox xpath="$currentButton" checked="false"/>
</repeat>
<repeat xpath="//input[@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:"//input[@type='checkbox']", counterName:"currentButton") {
verifyCheckbox xpath:"$currentButton", checked:"false"
}
repeat (xpath:"//input[@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.



pic18678.gif (1K) Download Attachment

Parent Message unknown Re: RE: Repeat step in a Groovy test case

by Beat Koch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
 

---- alessandro.conte@... 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                                                
>              <bidli@...                                        
>              >                                                          To
>              Sent by:                  webtest@...        
>              webtest-admin@gat                                          cc
>              e4.canoo.com                                              
>              15.06.2009 00:34                                      Subject
>                                        [Webtest] RE: Repeat step in a  
>                                        Groovy test case                
>              Please respond to                                        
>              webtest@...                                        
>                   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="//input[@type='checkbox']" counterName="currentButton">
>    <verifyCheckbox xpath="$currentButton" checked="false"/>
>  </repeat>
>  <repeat xpath="//input[@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:"//input[@type='checkbox']",
> counterName:"currentButton") {
>         verifyCheckbox xpath:"$currentButton", checked:"false"
>       }
>       repeat (xpath:"//input[@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
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

Re: RE: Repeat step in a Groovy test case

by Jean Hominal :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I don't know much about Groovy, but I think that it could be related
to that which is explained there:
http://docs.codehaus.org/display/GroovyJSR/Groovy+String+Handling

I would replace
>>         verifyCheckbox xpath:"$currentButton", checked:"false"
with:
verifyCheckbox xpath:'$currentButton', checked:"false"

(Replacing double quotes with simple quotes to avoid escaping).

Regards,
--
Jean
2009/6/16  <bidli@...>:

> 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
>
>
> ---- alessandro.conte@... 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
>>              <bidli@...
>>              >                                                          To
>>              Sent by:                  webtest@...
>>              webtest-admin@gat                                          cc
>>              e4.canoo.com
>>              15.06.2009 00:34                                      Subject
>>                                        [Webtest] RE: Repeat step in a
>>                                        Groovy test case
>>              Please respond to
>>              webtest@...
>>                   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="//input[@type='checkbox']" counterName="currentButton">
>>    <verifyCheckbox xpath="$currentButton" checked="false"/>
>>  </repeat>
>>  <repeat xpath="//input[@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:"//input[@type='checkbox']",
>> counterName:"currentButton") {
>>         verifyCheckbox xpath:"$currentButton", checked:"false"
>>       }
>>       repeat (xpath:"//input[@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
> WebTest@...
> http://lists.canoo.com/mailman/listinfo/webtest
>
_______________________________________________
WebTest mailing list
WebTest@...
http://lists.canoo.com/mailman/listinfo/webtest

Re: RE: Repeat step in a Groovy test case

by Marc Guillemot :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

you're right: repeat used with XPath doesn't store the counter as a
WebTest property as it is not really a counter but an element. The
"counter" is saved as XPath variable and therefore the syntax $rb here
should be interpreted by the XPath parser, not before by Groovy or by Ant.

Following should work:

repeat (xpath:"//input[@type='radio']", counterName:"rb") {
  verifyRadioButton xpath: '$rb', checked:"false"
}

Note the use of simple quotes instead of double quotes to use normal
strings and not GStrings.

Cheers,
Marc.
--
Web: http://www.efficient-webtesting.com
Blog: http://mguillem.wordpress.com


Jean Hominal wrote:

> I don't know much about Groovy, but I think that it could be related
> to that which is explained there:
> http://docs.codehaus.org/display/GroovyJSR/Groovy+String+Handling
>
> I would replace
>>>         verifyCheckbox xpath:"$currentButton", checked:"false"
> with:
> verifyCheckbox xpath:'$currentButton', checked:"false"
>
> (Replacing double quotes with simple quotes to avoid escaping).
>
> Regards,



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

Re: RE: Repeat step in a Groovy test case

by Beat Koch-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Marc, Jean,

Yes, it does work that way, with single quotes. Thanks a lot!

Regards, Beat


Am 16.06.2009 um 13:56 schrieb Marc Guillemot:

> Hi,
>
> you're right: repeat used with XPath doesn't store the counter as a
> WebTest property as it is not really a counter but an element. The
> "counter" is saved as XPath variable and therefore the syntax $rb here
> should be interpreted by the XPath parser, not before by Groovy or  
> by Ant.
>
> Following should work:
>
> repeat (xpath:"//input[@type='radio']", counterName:"rb") {
>  verifyRadioButton xpath: '$rb', checked:"false"
> }
>
> Note the use of simple quotes instead of double quotes to use normal
> strings and not GStrings.
>
> Cheers,
> Marc.
> --
> Web: http://www.efficient-webtesting.com
> Blog: http://mguillem.wordpress.com
>
>
> Jean Hominal wrote:
>> I don't know much about Groovy, but I think that it could be related
>> to that which is explained there:
>> http://docs.codehaus.org/display/GroovyJSR/Groovy+String+Handling
>>
>> I would replace
>>>>        verifyCheckbox xpath:"$currentButton", checked:"false"
>> with:
>> verifyCheckbox xpath:'$currentButton', checked:"false"
>>
>> (Replacing double quotes with simple quotes to avoid escaping).
>>
>> Regards,
>
>
>
> _______________________________________________
> WebTest mailing list
> WebTest@...
> http://lists.canoo.com/mailman/listinfo/webtest

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