<?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:
<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>