18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
Running a suite using Sahi
Build: 2011-05-17
Chrome : 17.0.963.78m
Firefox : 10.0.2
Windows XP
I have created a batch file that runs my test suite, this will enable us to integrate it into Jenkins at a future date:
My POM is as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">
<modelVersion>4.0.0</modelVersion>
<groupId>uk.co.insidertech.SAHIIntegrationTests</groupId>
<artifactId>SAHIIntegrationTests</artifactId>
<version>Latest_Sources</version>
<name>SAHIIntegrationTests</name>
<properties>
<productName>Sentra</productName>
<property environment="env"/>
<batchFileEcho>NO_ECHO</batchFileEcho>
<sahi.antFileName>${basedir}\SAHITests_ANT_Task.xml</sahi.antFileName>
<sahi.antTargetName>sahiRun_Browser</sahi.antTargetName>
<sahi.junitLogDir>${basedir}\generatedJUnitFiles\SAHI</sahi.junitLogDir>
<sahi.htmlLogDir>${basedir}\target\IntegrationTestResults</sahi.htmlLogDir>
<sahi.startDelaySecs>30</sahi.startDelaySecs>
<test.sahiSuiteRoot>${basedir}/scripts</test.sahiSuiteRoot>
<test.sahiSuiteName>${productName}_IntegrationTests.suite</test.sahiSuiteName>
<test.appWebServer>sql2008</test.appWebServer>
<test.appWebSite>http://${test.appWebServer}/SentraConsole</test.appWebSite>
<test.appDbServer>${test.appWebServer}</test.appDbServer>
<test.appDbAdminUser>sa</test.appDbAdminUser>
<test.appDbAdminPassword>=Password99</test.appDbAdminPassword>
<!--
Note: we need a different property when passing =Password99 to a batch file. We replace the = with (eq)
and the batch file converts it back to an =
-->
<test.appDbAdminPasswordBatch>(eq)Password99</test.appDbAdminPasswordBatch>
<test.appDatabaseName>${productName}</test.appDatabaseName>
</properties>
<build>
<plugins>
<!-- plugin to invoke commands, e.g. delete and/or create the database used for integration testing -->
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${basedir}\${productName}.SetParameters.xml</file>
<replacements>
<replacement>
<!--
Set the SahiTestingEnabled flag to true. This ensures that the application
switches behaviour in small areas, so that it is easier to test from SAHI.
e.g. Captcha box is displayed with a fixed value and validation of FF users
via email can be tested via a visible link, rather than having to automatically
read an email.
-->
<token>(?m)<setParameter name="SahiTestingEnabled-Web.config App Setting"(.|\s)*?\></token>
<value><setParameter name="SahiTestingEnabled-Web.config App Setting" value="true" /></value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>Write a SAHI settings file containing accessor functions for database settings and other values</id>
<phase>pre-integration-test</phase>
<configuration>
<tasks>
<exec
dir="${basedir}"
executable="CMD"
failonerror="false">
<arg line="/c DEL ${basedir}\scripts\MavenSettings.sah" />
</exec>
<exec
dir="${basedir}"
executable="${basedir}/appendSAHISettings.bat"
failonerror="true">
<arg line="${basedir}\scripts\MavenSettings.sah DbServerName:${test.appDbServer} DbUserName:${test.appDbAdminUser} DbPassword:${test.appDbAdminPasswordBatch} DbName:${test.appDatabaseName}" />
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>Start SAHI Tests using an ANT job</id>
<phase>integration-test</phase>
<configuration>
<tasks>
<ant antfile="${sahi.antFileName}">
<!-- pass properties to the ant job
<property name="sahi.startDelaySecs" value="${sahi.startDelaySecs}"/>
<property name="sahi.junitLogDir" value="${sahi.junitLogDir}"/>
<property name="sahi.htmlLogDir" value="${sahi.htmlLogDir}"/>
<property name="test.sahiSuiteRoot" value="${test.sahiSuiteRoot}"/>
<property name="test.sahiSuiteName" value="${test.sahiSuiteName}"/>
<property name="test.baseURL" value="${test.appWebSite}"/>
-->
<target name="${sahi.antTargetName}"/>
</ant>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
My POM also includes the following file, SAHITest_ANT_Task.xml, contents of which are attached below:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
An ANT job build file to execute SAHI integration tests.
This contains no project-sepcific settings. All settings are passed from Maven
via properties. Do not add project-specific settings to this file.
-->
<project name="RunSAHITests" default="sahiRun_Browser">
<taskdef name="sahi" classname="net.sf.sahi.ant.RunSahiTask" classpath="C:\Progra~1/sahi/lib/ant-sahi.jar"/>
<target name="start-sahi" description="start sahi proxy">
<java classname="net.sf.sahi.Proxy" fork="true" spawn="true" dir="C:\Progra~1/sahi">
<classpath location="C:\Progra~1/sahi/lib/sahi.jar">
<pathelement location="C:\Progra~1/sahi/extlib/rhino/js.jar"/>
<pathelement location="C:\Progra~1\MicrosoftJDBCDrivers\sqljdbc4.jar"/>
</classpath>
</java>
</target>
<target name="stop-sahi" description="stop sahi server">
<sahi stop="true" sahihost="localhost" sahiport="9999"/>
</target>
<target name="failsahi" if="sahi.failed">
<fail message="Sahi tests failed!"/>
</target>
<target name="sahiRun_Browser" description="start the server and run sahi tests against chrome ">
<parallel>
<sequential>
<antcall target="start-sahi"/>
<echo message="running tests for chrome browser, using ANT..."/>
<sahi suite="C:\Users\MooresD\Sentra\Latest_Sources\SAHIIntegrationTests\scripts\Test.suite"
browserType="chrome"
baseurl="http://sql2008/SentraConsole"
sahihost="localhost"
sahiport="9999"
failureproperty="sahi.failed"
haltonfailure="false"
singlesession="true"
threads="1">
</sahi>
<echo message="completed tests for chrome browser, using ANT"/>
<antcall target="failsahi"/>
<antcall target="stop-sahi"/>
</sequential>
</parallel>
</target>
<target name="sahiRun_XBrowser" description="start the server and run sahi tests using testrunner against firefox ">
<parallel>
<sequential>
<antcall target="start-sahi"/>
<echo message="running tests for firefox browser, using testrunner..."/>
<waitfor maxwait="15" maxwaitunit="second" checkevery="100">
<http url="http://sql2008/SentraConsole"/>
</waitfor>
<exec
dir="C:\Progra~1/sahi/userdata/bin"
executable="CMD"
failonerror="false">
<arg line="/c testrunner.bat Test.suite http://sql2008/SentraConsole chrome 1"/>
<!--
<arg line="/c testrunner.bat Test.suite http://sql2008.test.local/SentraConsole chrome"/>
<arg line="/c testrunner.bat Test.suite http://sql2008/SentraConsole chrome 1"/>
<arg line="/c testrunner.bat Test.suite http://yoda:8080/SentraConsole chrome 1"/>
<arg line="/c testrunner.bat Test.suite http://yoda.test.local:8080/SentraConsole chrome 1"/>
-->
</exec>
<echo message="completed tests for firefox browser, using testrunner"/>
<antcall target="failsahi"/>
<antcall target="stop-sahi"/>
</sequential>
</parallel>
</target>
</project>
I run my suite from the command line with the syntax:
mvn integration-test -Dmaven.test.skipDb -Dmaven.test.skipDeployWeb -Dtest.sahiSuiteName="Test.suite"
where Test.suite contains a simple script file that tests some controls displayed on the screen.
When the command executes a browser is launched, but the full initial start url is never displayed.
I have increased all the timeouts in the sahi.properties file, yet this makes no difference. (details available on request), and I have also increased the max buffer size with no luck.
I have added additional logging and noticed that an attempt is made to get the page at 10 second intervals, after 10 seconds the page hasn't fully loaded, so repeated attempts are made to load the page, which are again unsuccessful, this repeats until the max time is reached and the process is terminated.
The file size of the page that is being loaded is 10Mb.
Please can you provide some assistance on how to resolve this problem
Many thanks
Donna
Chrome : 17.0.963.78m
Firefox : 10.0.2
Windows XP
I have created a batch file that runs my test suite, this will enable us to integrate it into Jenkins at a future date:
My POM is as follows:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd\">
<modelVersion>4.0.0</modelVersion>
<groupId>uk.co.insidertech.SAHIIntegrationTests</groupId>
<artifactId>SAHIIntegrationTests</artifactId>
<version>Latest_Sources</version>
<name>SAHIIntegrationTests</name>
<properties>
<productName>Sentra</productName>
<property environment="env"/>
<batchFileEcho>NO_ECHO</batchFileEcho>
<sahi.antFileName>${basedir}\SAHITests_ANT_Task.xml</sahi.antFileName>
<sahi.antTargetName>sahiRun_Browser</sahi.antTargetName>
<sahi.junitLogDir>${basedir}\generatedJUnitFiles\SAHI</sahi.junitLogDir>
<sahi.htmlLogDir>${basedir}\target\IntegrationTestResults</sahi.htmlLogDir>
<sahi.startDelaySecs>30</sahi.startDelaySecs>
<test.sahiSuiteRoot>${basedir}/scripts</test.sahiSuiteRoot>
<test.sahiSuiteName>${productName}_IntegrationTests.suite</test.sahiSuiteName>
<test.appWebServer>sql2008</test.appWebServer>
<test.appWebSite>http://${test.appWebServer}/SentraConsole</test.appWebSite>
<test.appDbServer>${test.appWebServer}</test.appDbServer>
<test.appDbAdminUser>sa</test.appDbAdminUser>
<test.appDbAdminPassword>=Password99</test.appDbAdminPassword>
<!--
Note: we need a different property when passing =Password99 to a batch file. We replace the = with (eq)
and the batch file converts it back to an =
-->
<test.appDbAdminPasswordBatch>(eq)Password99</test.appDbAdminPasswordBatch>
<test.appDatabaseName>${productName}</test.appDatabaseName>
</properties>
<build>
<plugins>
<!-- plugin to invoke commands, e.g. delete and/or create the database used for integration testing -->
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${basedir}\${productName}.SetParameters.xml</file>
<replacements>
<replacement>
<!--
Set the SahiTestingEnabled flag to true. This ensures that the application
switches behaviour in small areas, so that it is easier to test from SAHI.
e.g. Captcha box is displayed with a fixed value and validation of FF users
via email can be tested via a visible link, rather than having to automatically
read an email.
-->
<token>(?m)<setParameter name="SahiTestingEnabled-Web.config App Setting"(.|\s)*?\></token>
<value><setParameter name="SahiTestingEnabled-Web.config App Setting" value="true" /></value>
</replacement>
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>Write a SAHI settings file containing accessor functions for database settings and other values</id>
<phase>pre-integration-test</phase>
<configuration>
<tasks>
<exec
dir="${basedir}"
executable="CMD"
failonerror="false">
<arg line="/c DEL ${basedir}\scripts\MavenSettings.sah" />
</exec>
<exec
dir="${basedir}"
executable="${basedir}/appendSAHISettings.bat"
failonerror="true">
<arg line="${basedir}\scripts\MavenSettings.sah DbServerName:${test.appDbServer} DbUserName:${test.appDbAdminUser} DbPassword:${test.appDbAdminPasswordBatch} DbName:${test.appDatabaseName}" />
</exec>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>Start SAHI Tests using an ANT job</id>
<phase>integration-test</phase>
<configuration>
<tasks>
<ant antfile="${sahi.antFileName}">
<!-- pass properties to the ant job
<property name="sahi.startDelaySecs" value="${sahi.startDelaySecs}"/>
<property name="sahi.junitLogDir" value="${sahi.junitLogDir}"/>
<property name="sahi.htmlLogDir" value="${sahi.htmlLogDir}"/>
<property name="test.sahiSuiteRoot" value="${test.sahiSuiteRoot}"/>
<property name="test.sahiSuiteName" value="${test.sahiSuiteName}"/>
<property name="test.baseURL" value="${test.appWebSite}"/>
-->
<target name="${sahi.antTargetName}"/>
</ant>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
My POM also includes the following file, SAHITest_ANT_Task.xml, contents of which are attached below:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
An ANT job build file to execute SAHI integration tests.
This contains no project-sepcific settings. All settings are passed from Maven
via properties. Do not add project-specific settings to this file.
-->
<project name="RunSAHITests" default="sahiRun_Browser">
<taskdef name="sahi" classname="net.sf.sahi.ant.RunSahiTask" classpath="C:\Progra~1/sahi/lib/ant-sahi.jar"/>
<target name="start-sahi" description="start sahi proxy">
<java classname="net.sf.sahi.Proxy" fork="true" spawn="true" dir="C:\Progra~1/sahi">
<classpath location="C:\Progra~1/sahi/lib/sahi.jar">
<pathelement location="C:\Progra~1/sahi/extlib/rhino/js.jar"/>
<pathelement location="C:\Progra~1\MicrosoftJDBCDrivers\sqljdbc4.jar"/>
</classpath>
</java>
</target>
<target name="stop-sahi" description="stop sahi server">
<sahi stop="true" sahihost="localhost" sahiport="9999"/>
</target>
<target name="failsahi" if="sahi.failed">
<fail message="Sahi tests failed!"/>
</target>
<target name="sahiRun_Browser" description="start the server and run sahi tests against chrome ">
<parallel>
<sequential>
<antcall target="start-sahi"/>
<echo message="running tests for chrome browser, using ANT..."/>
<sahi suite="C:\Users\MooresD\Sentra\Latest_Sources\SAHIIntegrationTests\scripts\Test.suite"
browserType="chrome"
baseurl="http://sql2008/SentraConsole"
sahihost="localhost"
sahiport="9999"
failureproperty="sahi.failed"
haltonfailure="false"
singlesession="true"
threads="1">
</sahi>
<echo message="completed tests for chrome browser, using ANT"/>
<antcall target="failsahi"/>
<antcall target="stop-sahi"/>
</sequential>
</parallel>
</target>
<target name="sahiRun_XBrowser" description="start the server and run sahi tests using testrunner against firefox ">
<parallel>
<sequential>
<antcall target="start-sahi"/>
<echo message="running tests for firefox browser, using testrunner..."/>
<waitfor maxwait="15" maxwaitunit="second" checkevery="100">
<http url="http://sql2008/SentraConsole"/>
</waitfor>
<exec
dir="C:\Progra~1/sahi/userdata/bin"
executable="CMD"
failonerror="false">
<arg line="/c testrunner.bat Test.suite http://sql2008/SentraConsole chrome 1"/>
<!--
<arg line="/c testrunner.bat Test.suite http://sql2008.test.local/SentraConsole chrome"/>
<arg line="/c testrunner.bat Test.suite http://sql2008/SentraConsole chrome 1"/>
<arg line="/c testrunner.bat Test.suite http://yoda:8080/SentraConsole chrome 1"/>
<arg line="/c testrunner.bat Test.suite http://yoda.test.local:8080/SentraConsole chrome 1"/>
-->
</exec>
<echo message="completed tests for firefox browser, using testrunner"/>
<antcall target="failsahi"/>
<antcall target="stop-sahi"/>
</sequential>
</parallel>
</target>
</project>
I run my suite from the command line with the syntax:
mvn integration-test -Dmaven.test.skipDb -Dmaven.test.skipDeployWeb -Dtest.sahiSuiteName="Test.suite"
where Test.suite contains a simple script file that tests some controls displayed on the screen.
When the command executes a browser is launched, but the full initial start url is never displayed.
I have increased all the timeouts in the sahi.properties file, yet this makes no difference. (details available on request), and I have also increased the max buffer size with no luck.
I have added additional logging and noticed that an attempt is made to get the page at 10 second intervals, after 10 seconds the page hasn't fully loaded, so repeated attempts are made to load the page, which are again unsuccessful, this repeats until the max time is reached and the process is terminated.
The file size of the page that is being loaded is 10Mb.
Please can you provide some assistance on how to resolve this problem
Many thanks
Donna
Comments
Thanks
Donna