Hello all,

I just startet to use Canoo WebTest to functionally test some web
applications. I did use the auto generated tests in a grails project
beforehand.

I understand, that I can use groovy scripts in groovy steps from an xml
test definition like explained here:
http://webtest.canoo.com/webtest/manual/groovy.html

However I find the approach, grails generated, i.e. test classes
extending grails.util.WebTest very elegant. 

Is there a chance to use grails.util.WebTest outside of a grails
project? How would I do that?

Here is the minimal example I use for now, wich runs but feels "clumsy"
in comparison:

build.xml:
/--
<project name="BI IDEA Use Case Tests">
        <property name="webtest.resultpath" value="webtest-results" />
        <property name="webtest.resultfile" value="results.xml"/>
        <property name="webtest.resultfile.html" value="results.html"/>
        <property environment="env"/>
        <property name="env.WEBTEST_HOME" location="/opt/webtest"/>

        <property name="webtest.home" location="${env.WEBTEST_HOME}"/>
        <property name="testInWork" value="main"/>

        <description>
                <![CDATA[
                        Invoke the webtest scripts to invoke functional 
webtests on the
Interface
                ]]>
        </description>
        <import file="${webtest.home}/lib/useWebTest.xml" />

</project>
\--

main.xml:
/--
...
<project name="testMe" basedir="." default="main">
<property environment="env" />
        <import file="${env.WEBTEST_HOME}/lib/taskdef.xml" />

        <target name="main">

                <webtest name="googletest">
                &config;
                <steps>
                                <groovy replaceProperties="false" 
file="GoogleStep.groovy" />
                        </steps>
                </webtest>
</target>

</project>

GoogleStep.groovy:
/--
def ant = new AntBuilder()
def webtest_home = "/opt/webtest"

ant.taskdef(resource:'webtest.taskdef'){
    classpath(){
           pathelement(location:"$webtest_home/lib")
           fileset(dir:"$webtest_home/lib", includes:"**/*.jar")
    }
}

ant.webtest(name:'Test Google with Groovy, AntBuilder and WebTest'){
    steps(){
        invoke(url:'http://www.google.com')
        verifyTitle(text:'Google')
        setInputField(name:'q', value:'Groovy')
        clickButton(name:'btnG')
        verifyXPath(xpath:"//[EMAIL PROTECTED]'http://groovy.codehaus.org/']")
    }
}
\--

Any thoughts?
-- 
André Schaefer

Raytion GmbH
Kaiser-Friedrich-Ring 74
40547 Duesseldorf
Germany

www.raytion.com


Fon +49. 211. 55 02 66. 0
Fax +49. 211. 55 02 66. 19

_______________________________________________
WebTest mailing list
[email protected]
http://lists.canoo.com/mailman/listinfo/webtest

Reply via email to