18 January 2026:


This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.



Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.

Not able to Run Sahi using ANT

jaydeepcjaydeepc Members
edited November -1 in Sahi - Open Source
Hi, I am using the following ANT task to run the test:

<?xml version="1.0" encoding="ISO-8859-1"?>
<project name="all" default="runbrowsertests">
<taskdef name="sahi" classname="net.sf.sahi.ant.RunSahiTask" classpath="lib/ant-sahi.jar"/>
<target name="failsahi" if="sahi.failed">
<fail message="Sahi tests failed!"/>
</target>
<target name="runbrowsertests">
<sahi suite="../userdata/scripts/cri.suite"
browserType="ff"
browser="C:\Program Files\Mozilla Firefox\firefox.exe"
baseurl="baseurl"
sahihost="localhost"
sahiport="9999"
failureproperty="sahi.failed"
haltonfailure="false"
threads="3"
>
</sahi>
<antcall target="failsahi"/>
</target>
</project>

But when I try to Run the test, It says, "Connection Refused: connect".


BUILD FAILED
C:\Monitor CRI Data\sahi\build.xml:19: The following error occurred while execut
ing this line:
C:\Monitor CRI Data\sahi\build.xml:5: Sahi tests failed!

Total time: 1 second
Shutting down ...
Connection refused: connect

Please help. What am I missing?

Thanks,
Jaydeep

Comments

  • narayannarayan Administrators
    Hi Jaydeep,

    You need to start Sahi before you run your ant task.

    Regards,
    Narayan
  • Hey Narayan,

    Thanks for the quick reply. So, there is a Task inside the demo.xml which starts the server. Can I add that to my ant task so that ther server is automatically started?

    Thanks,
    Jaydeep
  • Hi Narayan,

    I am using the demo.xml to run my test. There is a task "Start" which I think starts the Sahi Server. (Isn't it?). In "runffsingle" target, I added the "Start" as depends. But the problem is when I try to run it through ANT, It first calls the Start task and starts the server, but after that it does not start the runffsingle. The same is happening if I remove the Start from depends and add that as <antcall> inside the runffsingle task.

    If I start the server manually and try to start the runffsingle, it starts correctly and gets executed.

    Please help.

    Thanks,
    Jaydeep
  • nickleusnickleus Members
    edited November 2012
    i got the same "Connection Refused" error when running my sahi task in ant and fixed it by inserting a sleep call in the ant target that starts the sahi proxy:
    <target name="start-web" description="starts web">
    <exec executable="../testing/sahi/userdata/bin/start_sahi.sh" osfamily="unix" spawn="true"/>
    <sleep seconds="5"/>
    </target>

    this, to allow the proxy server enough time to start up before running the sahi task.

    i also had to convert all my paths to fully qualified paths instead of relative, e.g.:
    change:
    <sahi suite="../testing/functional_testing/stage_1/sahi/smoketest.suite"
    to:
    <sahi suite="/home/me/workspace/myApp/testing/functional_testing/stage_1/sahi/smoketest.suite"

    and all other places that require some kind of path.

    i also did this in files like:
    sahi/userdata/bin/start_sahi.sh
    sahi/userdata/bin/testrunner.sh
    sahi/bin/sahi.sh
Sign In or Register to comment.