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.

Automatic email sending when a script finished execution as suite file

GeorgeGeorge Members
edited November -1 in Sahi - Open Source
I want an email to be send to my email-id automatically by sahi controller after my sahi script is run (i scheduled to run the sahi script as a batch/suite from my machine everyday).

I search the forum for this solution.. but coudn't find any.
Pl advise.

george

Comments

  • Narayan/Administrator

    pl help me on this matter...
    i changed the mail from & mail to .. in the config.propertis file also.. but no result.

    george
  • Hi George,

    Here is the explanation to send an email after the execution of the script.

    Firstly you need to have the Activation jar file, mail jar file and Java Secure Socket Extension jar file. Download the above jar files from the below URL and should be copied into the Ant lib directory.

    http://www.vincentkong.com/2008/12/sending-email-with-ant

    Use the below ant target in any of the xml file:
    <target name="runsendmailtests"> 
            <sahi suite="../userdata/scripts/demo/demo2.suite"
                  browserType="firefox5"
                  baseurl="http://${urlbase}/demo/"
                  sahihost="localhost"
                  sahiport="9999"
                  failureproperty="sahi.failed"
                  haltonfailure="false"
                  threads="6">
                <report type="html"/>
                
                <!--<report type="junit" logdir="${userdata.dir}/temp/junit"/>-->
            </sahi>    
               <antcall target="failsahi"/>
               <antcall target="sahipass"/>
        </target>
    

    The target file for "failsahi" and "sahipass" are as below.
    <target name="failsahi" if="sahi.failed">
            <!--antcall target="stop-web"/-->
            <mail tolist="xxxxx@gmail.com"
                  from="xxxxx@gmail.com"
                  subject="Email subject"
                  mailhost="smtp.gmail.com"
                  mailport="465"
                  ssl="true"
                  user="xxxxx@gmail.com"
                  password="xxxxxxx">
            <message>Sahi build failed</message>
            </mail>
            <fail message="Sahi tests failed!"/>
        </target>
    
    <target name="sahipass" unless="sahi.failed">
            <!--antcall target="stop-web"/-->
            <mail tolist="xxxxxx@gmail.com"
                  from="xxxxxx@gmail.com"
                  subject="Email subject"
                  mailhost="smtp.gmail.com"
                  mailport="465"
                  ssl="true"
                  user="xxxxx@gmail.com"
                  password="xxxxxx">
            <message>Sahi build passed</message>
            </mail>
        </target>
    

    Now, navigate to the xml file and run runsendmailtests ant target using:

    ant -f demo.xml runsendmailtests

    Let me know if you face any problem.

    Regards
    Sumitra
  • I also have this problem. My question is not "send Email from CI tool, like Hudson", but directly by Sahi. After setting SMTP server and Email account in scheduler.properties, no Email was sent out.
  • Hi Karen,

    Can you please look at this :

    http://groups.google.com/group/sahi/browse_thread/thread/ce9cb8843ce91037?pli=1

    Check if this solves your issue.

    Regards
    Sumitra
  • hi the above url is not working

    please use this url for

    http://blog.vincentkong.com/2008/12/sending-email-with-ant
  • mohanmohan Members
    hi George,

    could you please expalin me about the scheduler configuration and also about using ant targets. i need to know how to configure ant and sahi.
Sign In or Register to comment.