SourceForge.net Logo

Sahi - Web Automation and Test Tool


Documentation in this directory is not current. Please visit http://sahi.co.in/ for the latest documentation.


Ant Integration

Sahi

Description

Runs a suite of sahi files. This opens multiple browser windows , executes sahi scripts, and logs the results. The build can be made to fail based on a failureproperty.

Parameters

Attribute Description Required
suite path to suite file
browser Path to browser executable
baseurl url relative to which all urls to be tested will be resolved
sahihost IP or hostname of server where sahi is running
sahiport port where sahi is running
failureproperty Name of property which will be set to false in case build fails.
haltonfailure Takes "true" or "false". Specifies if build should stop executing other tests if one test fails.
threads Number of simultaneous browser instances where sahi tests will be run. Do not use this property if using firefox. optional
logdir Directory to output this suite's results. If absent, uses the default playback logs dir. optional


Example

build xml for running the sample web server bundled with sahi.

The demo could be run by running "ant -f demo.xml sahitests" from the sahi base folder.

<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="demo" default="sahitests">
    <taskdef name="sahi" classname="net.sf.sahi.ant.RunSahiTask" classpath="lib/ant-sahi.jar"/>

    <target name="sahitests" description="start the server and run sahi tests">
        <parallel>
            <sequential>
                <waitfor maxwait="3" maxwaitunit="minute" checkevery="100">
                    <http url="http://localhost:10000/demo/index.htm"/>
                </waitfor>
                <antcall target="proxyon"/>
                <sahi suite="../scripts/demo.suite"
                    browser="C:\\Program Files\\Internet Explorer\\iexplore.exe"
                    baseurl="http://localhost:10000/demo/"
                    sahihost="localhost"
                    sahiport="9999"
                    failureproperty="sahi.failed"
                    haltonfailure="false"
                    threads="2"
                    logdir="D:\demo\logs"
                    />
                <antcall target="proxyoff"/>
                <antcall target="stop-web"/>
                <antcall target="failsahi"/>
            </sequential>
            <antcall target="start-web"/>
        </parallel>
    </target>

    <target name="failsahi" if="sahi.failed">
        <fail message="Sahi tests failed!"/>
    </target>

    <target name="start-web" description="starts web">
        <java classname="net.sf.sahi.WebServer" fork="true" dir="bin" >
            <classpath location="lib/sahi.jar"/>
        </java>
    </target>

    <target name="stop-web" description="stop web server">
        <get dest="stopserver.htm" src="http://localhost:10000/dyn/stopserver" ignoreerrors="true" />
        <delete file="stopserver.htm"/>
    </target>


    <target name="sahireport" description="show report">
        <exec command="C:\\Program Files\\Internet Explorer\\iexplore.exe file:///C:/my/sahi/logs/playback/"/>
    </target>

    <target name="start" description="starts proxy">
        <java classname="net.sf.sahi.Proxy" fork="true" dir="bin">
            <classpath location="lib/sahi.jar"/>
        </java>
    </target>

    <target name="proxyon">
        <exec executable="tools/toggle_IE_proxy.exe">
            <arg value="enable"/>
        </exec>
    </target>
    
    <target name="proxyoff">
        <exec executable="tools/toggle_IE_proxy.exe">
            <arg value="disable"/>
        </exec>
    </target>

</project>

Please send your feedback to V Narayan Raman.