Playback via Ant
abstract
This section describes playing back Sahi scripts via Apache Ant.
Playback on a single machine
One can now use the Editor Playback UI to generate the ANT xml automatically. Refer here for details on the UI.- Choose the
Run in parallel
option. - Click the
Create Ant Target
button
Add Retry Target
button on the next window.
Once the ANT xml content is generated, copy the content to an empty file and save the file as an xml, say
demo.xml
in your <SAHI_INSTALLATION_FOLDER>
.
You can now run the default ANT target in the xml file as
ant -f demo.xml
NOTE: The main target is the default target, so you do not need to specify the target when running the xml.
The above UI would generate an ANT xml that looks like the following.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
/**
* Copyright Tyto Software Pvt. Ltd.
*/
-->
<project name="demo" default="runtestsie">
<taskdef name="sahi" classname="net.sf.sahi.ant.RunSahiTask" classpath="lib/ant-sahi.jar"/>
<target name="set_timestamp">
<tstamp>
<format property="ts" pattern="yyyy_MM_dd__HH_mm_ss" locale="en, IN"/>
</tstamp>
</target>
<target name="set_properties_ie" depends="set_timestamp">
<property name="scriptDir" value="D:/dev/SahiPro/userdata/scripts/"/>
<property name="scriptName" value="sahitests/ddcsv/test.dd.csv"/>
<property name="browser" value="ie"/>
<property name="startWith" value="BROWSER"/>
<property name="sendemail" value="true"/>
<property name="emailtrigger" value="success,failure"/>
<property name="emailproperties" value="D:\dev\SahiPro\userdata\config\email.properties"/>
<property name="sendemailForSubSuite" value="false"/>
<property name="sendemailperiodically" value="true"/>
<property name="sendemailperiodicallytime" value="30"/>
<property name="emailPasswordHidden" value="true"/>
<property name="baseURL" value="http://sahitest.com/demo/training/"/>
<property name="host" value="localhost"/>
<property name="port" value="9999"/>
<property name="singlesession" value="false"/>
<property name="threads" value="5"/>
<property name="abortedRetryCount" value="0"/>
<property name="failureRetryCount" value="0"/>
<property name="isAvoidSkipping" value="false"/>
<property name="isAutohealEnabled" value="false"/>
<property name="suiteTimeOut" value="0.0"/>
<property name="showPeriodicSummary" value="true"/>
<property name="failedSuiteName" value="test_failed_${browser}.dd.csv"/>
<property name="failedSuite" value="sahitests/ddcsv/${failedSuiteName}"/>
<property name="jsCodeCoverage" value="false"/>
</target>
<target name="runtestsie" depends="set_properties_ie">
<sahi suite="${scriptName}"
browsertype="${browser}"
startWith="${startWith}"
sendemail="${sendemail}"
emailtrigger="${emailtrigger}"
emailproperties="${emailproperties}"
sendEmailForSubSuite="${sendemailForSubSuite}"
sendEmailPeriodically="${sendemailperiodically}"
sendEmailPeriodicallyTime="${sendemailperiodicallytime}"
emailPasswordHidden="${emailPasswordHidden}"
baseurl="${baseURL}"
sahihost="${host}"
sahiport="${port}"
scriptsPathMaster="${scriptDir}"
failureproperty="sahi.failed.${browser}"
failedSuiteName="${failedSuiteName}"
haltonfailure="false"
singlesession="${singlesession}"
showPeriodicSummary="${showPeriodicSummary}"
threads="${threads}"
abortedRetryCount="${abortedRetryCount}"
failureRetryCount="${failureRetryCount}"
isAvoidSkipping="${isAvoidSkipping}"
isAutohealEnabled="${isAutohealEnabled}"
suiteTimeOut="${suiteTimeOut}"
jsCodeCoverage="${jsCodeCoverage}"
tags="(user||admin)&&medium"
userDefinedId="IETestRun1">
<!-- Custom fields - add, edit or remove as required -->
<customfield key="user" value="test"/>
<customfield key="mask_password" value="secret"/>
<!-- Offline reports -->
<report type="xml"/>
<report type="html" logdir="D:\temp\html"/>
</sahi>
<antcall target="failsahiie"/>
</target>
<target name="failsahiie" depends="set_properties_ie" if="sahi.failed.${browser}">
<fail message="Sahi tests failed on browser ${browser}!"/>
</target>
</project>
info
If you choose the
Run sequentially in single browser session
option, singlesession attribute would be set to true. Everything else remains the same.
danger
NOTE:
The above XML content is for illustration purposes only. Use the Editor UI to generate the ANT xml content and create an xml with that content in your
Let us look at the important attributes used in the ANT xml target (specified in bold above).
<SAHI_INSTALLATION_FOLDER>
.
Attributes and their description
info
taskdef classpath is relative to where ant is run from.
scriptDir | Specifies the path to the scripts folder. Can be the absolute path or a path relative to the userdata folder |
scriptName | Relative path to the script/suite/data driven suite. It is relative to scriptDir. |
browser | The browser on which the suite file plays back |
baseurl | Specifies URL which is the starting URL for all the scripts in the suite |
host | Hostname of the server where Sahi is running (Can be IP as well) |
port | Port on which Sahi is running |
threads | Number of simultaneous browser instances on which sahi tests will be run. |
singlesession | Since this is a parallel run, it will be "false". If "true", runs all scripts in a single browser without closing it between scripts. |
showPeriodicSummary | Takes "true" or "false". If "true", a periodic summary of script status is logged in the Ant Console. |
isAutohealEnabled | Takes "true" or "false". If "true", allows scripts to pick element using Sahi auto intelligence when element provided in script is not found. Refer Autoheal section for more details. |
sendemail | Takes "true" or "false". If "true", Sahi sends an email summarizing the playback. |
emailtrigger | Takes "success" or "failure" or "success,failure". Triggers email in case of SUCCESS, FAILURE and both cases respectively. |
emailproperties | Path to the properties file that contains details about the mail viz. information about the sender, receiver, host, port, subject, content etc. Path can be the absolute path or relative to where this ant target is run from. |
sendemailperiodically | Takes "true" or "false". If "true", Sahi will send emails periodically till the suite run is complete. |
sendemailperiodicallytime | Specifies the interval in minutes at which periodic emails are to be sent. |
failedSuiteName | Name of the failed suite. It is of the form <suitename>_failed_<browser>.suite . |
failedsuite | Relative path to the failed suite. It is relative to scriptDir. |
tags | Tags should be specified only for dd.csv and .csv suites. Tags are specified so that it is easy to choose which scripts/testcases to run. eg. in the target above, all the scripts which have 'medium' tag and 'admin' or 'user' (or both) tag will be run. |
userdefinedid | The unique id that the user can pass to differentiate a suite from others. This is an optional attribute. |
customfield | Custom fields can be passed to the scripts using the customfield attribute. More than one custom field can be passed, by specifying additional customfield entries. Replace the custom field keys and values as appropriate. This is an optional attribute. |
report | Sahi can set offline logs to be generated in xml , html , junit , tm6 and excel types. The default type is html . Add separate entries for each report type as required. This is an optional attribute. |
ant -f demo.xml
Distributed playback via ANT
Distributed playback can be achieved through ANT targets as well.These targets can be used from Jenkins to distribute the scripts of a suite on multiple machines.
The machine which distributes the scripts and manages the distributed run is referred to as the
Master
. All logs are visible from the Master
. The other machines are called Slaves
. Any machine in the distributed environment can serve as the Master
. The machine which launches the distributed run is referred to as the Initiator
.
Distributed run on the same Master
Use the Editor Playback UI to generate the ANT xml content.In the Editor Playback UI,
- Choose
Run distributed (multiple machines)
option. - Leave the
Use Different Master
checkbox unchecked. - Click on
Create Ant Target
button.
Add Retry Target
button on the next window.
Once the ANT xml content is generated, copy the content to an empty file and save the file as an xml, say
demo.xml
in your <SAHI_INSTALLATION_FOLDER>
.
You can now run the default ANT target in the xml file as
ant -f demo.xml
NOTE: The main target is the default target, so you do not need to specify the target when running the xml.
The above UI would generate an ANT xml that looks like the following.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
/**
* Copyright Tyto Software Pvt. Ltd.
*/
-->
<project name="demo" default="drunie">
<taskdef name="sahid" classname="in.co.sahi.ant.DAntRunner" classpath="lib/ant-sahi.jar"/>
<target name="set_timestamp">
<tstamp>
<format property="ts" pattern="yyyy_MM_dd_HH_mm_ss" locale="en, IN"/>
</tstamp>
</target>
<target name="set_properties_common" depends="set_timestamp">
<property name="scriptDir" value="D:/dev/SahiPro/userdata/scripts/"/>
<property name="host" value="localhost"/>
<property name="port" value="9999"/>
</target>
<target name="set_properties_ie" depends="set_properties_common">
<property name="scriptName" value="sahitests/ddcsv/test.dd.csv"/>
<property name="browser" value="ie"/>
<property name="startWith" value="BROWSER"/>
<property name="sendemail" value="true"/>
<property name="emailtrigger" value="success,failure"/>
<property name="emailproperties" value="D:\dev\SahiPro\userdata\config\email.properties"/>
<property name="sendemailForSubSuite" value="false"/>
<property name="sendemailperiodically" value="true"/>
<property name="sendemailperiodicallytime" value="30"/>
<property name="emailPasswordHidden" value="true"/>
<property name="baseURL" value="http://sahitest.com/demo/training/"/>
<property name="failedSuiteName" value="test_failed_${browser}.dd.csv"/>
<property name="failedSuite" value="sahitests/ddcsv/${failedSuiteName}"/>
<property name="showPeriodicSummary" value="true"/>
<property name="threads" value="5"/>
<property name="abortedRetryCount" value="0"/>
<property name="failureRetryCount" value="0"/>
<property name="isAvoidSkipping" value="false"/>
<property name="isSyncConfig" value="false"/>
<property name="isAutohealEnabled" value="false"/>
<property name="jsCodeCoverage" value="false"/>
<property name="suiteTimeOut" value="0.0"/>
</target>
<target name="drunie" depends="set_properties_ie, set_timestamp">
<sahid suite="${scriptName}"
sendEmail="${sendemail}"
emailtrigger="${emailtrigger}"
emailProperties="${emailproperties}"
sendEmailForSubSuite="${sendemailForSubSuite}"
sendEmailPeriodically="${sendemailperiodically}"
sendEmailPeriodicallyTime="${sendemailperiodicallytime}"
emailPasswordHidden="${emailPasswordHidden}"
baseurl="${baseURL}"
sahihost="${host}"
sahiport="${port}"
failureproperty="sahi.failed.${browser}"
failedSuiteName="${failedSuiteName}"
haltonfailure="false"
browsertype="${browser}"
startWith="${startWith}"
scriptsPathMaster="${scriptDir}"
threads="${threads}"
abortedRetryCount="${abortedRetryCount}"
failureRetryCount="${failureRetryCount}"
isAvoidSkipping="${isAvoidSkipping}"
isSyncConfig="${isSyncConfig}"
isAutohealEnabled="${isAutohealEnabled}"
jsCodeCoverage="${jsCodeCoverage}"
suiteTimeOut="${suiteTimeOut}"
showPeriodicSummary="${showPeriodicSummary}"
ignorePattern=".*(svn|copied).*"
tags="(user||admin)&&medium"
userDefinedId="IETestRun1">
<!-- Custom fields - add, edit or remove as required -->
<customfield key="user" value="test"/>
<customfield key="mask_password" value="secret"/>
<!-- Scripts will be distributed across all the nodes. The nodes may or may not include the Master machine -->
<node host="localhost" port="9999"/>
<node host="192.168.1.29" port="9999"/>
<!-- Offline reports -->
<report type="xml"/>
<report type="html" logdir="D:\temp\html"/>
</sahid>
<antcall target="failsahiie"/>
</target>
<target name="failsahiie" depends="set_properties_ie" if="sahi.failed.${browser}">
<fail message="Sahi tests failed on browser ${browser}!"/>
</target>
</project>
danger
NOTE:
The above XML content is for illustration purposes only. Use the Editor UI to generate the ANT xml content and create an xml with that content in your
Let us look at the important attributes used in the ANT xml target (specified in bold above).
<SAHI_INSTALLATION_FOLDER>
.
Attributes and their description
info
taskdef classpath is relative to where ant is run from.
scriptDir | Specifies the path to the scripts folder. Can be the absolute path or a path relative to the userdata folder |
host | Hostname of the server where Sahi is running (Can be IP as well). Leave this as localhost |
port | Port on which Sahi is running |
scriptName | Relative path to the script/suite/data driven suite. It is relative to scriptDir. |
browser | The browser on which the suite file plays back |
threads | Number of simultaneous browser instances on which sahi tests will be run. |
showPeriodicSummary | Takes "true" or "false". If "true", a periodic summary of script status is logged in the Ant Console. |
isAutohealEnabled | Takes "true" or "false". If "true", allows scripts to pick element using Sahi auto intelligence when element provided in script is not found. Refer Autoheal section for more details. |
baseurl | Specifies URL which is the starting URL for all the scripts in the suite |
sendemail | Takes "true" or "false". If "true", Sahi sends an email summarizing the playback. |
emailtrigger | Takes "success" or "failure" or "success,failure". Triggers email in case of SUCCESS, FAILURE and both cases respectively. |
emailproperties | Path to the properties file that contains details about the mail viz. information about the sender, receiver, host, port, subject, content etc. Path can be the absolute path or relative to where this ant target is run from. |
sendemailperiodically | Takes "true" or "false". If "true", Sahi will send emails periodically till the suite run is complete. |
sendemailperiodicallytime | Specifies the interval in minutes at which periodic emails are to be sent. |
failedSuiteName | Name of the failed suite. It is of the form <suitename>_failed_<browser>.suite . |
failedsuite | Relative path to the failed suite. It is relative to scriptDir. |
tags | Tags should be specified only for dd.csv and .csv suites. Tags are specified so that it is easy to choose which scripts/testcases to run. eg. in the target above, all the scripts which have 'medium' tag and 'admin' or 'user' (or both) tag will be run. |
userdefinedid | The unique id that the user can pass to differentiate a suite from others. This is an optional attribute. |
node | Each node attribute specifies a machine on which the tests should run. Add as many node entries as there are machines to run. The nodes may or may not include the Master machine (localhost). If the Master machine is not included, scripts will not be run on the Master . There can be 1 or more nodes.
|
customfield | Custom fields can be passed to the scripts using the customfield attribute. More than one custom field can be passed, by specifying additional customfield entries. Replace the custom field keys and values as appropriate. This is an optional attribute. |
report | Sahi can set offline logs to be generated in xml , html , junit , tm6 and excel types. The default type is html . Add separate entries for each report type as required. This is an optional attribute. |
ant -f demo.xml
Distributed run on a different Master
Use the Editor Playback UI to generate the ANT xml content.In the Editor Playback UI,
- Choose
Run distributed (multiple machines)
option. - Check the
Use Different Master
checkbox and choose the Master details. - Click on
Create Ant Target
button.
Add Retry Target
button on the next window.
Once the ANT xml content is generated, copy the content to an empty file and save the file as an xml, say
demo.xml
in your <SAHI_INSTALLATION_FOLDER>
.
You can now run the default ANT target in the xml file as
ant -f demo.xml
NOTE: The main target is the default target, so you do not need to specify the target when running the xml.
The above UI would generate an ANT xml that looks like the following.
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
/**
* Copyright Tyto Software Pvt. Ltd.
*/
-->
<project name="demo" default="drundiffmasterie">
<taskdef name="sahid" classname="in.co.sahi.ant.DAntRunner" classpath="lib/ant-sahi.jar"/>
<taskdef name="sahisync" classname="in.co.sahi.ant.DAntSync" classpath="lib/ant-sahi.jar"/>
<taskdef name="sahipull" classname="in.co.sahi.ant.DAntPull" classpath="lib/ant-sahi.jar"/>
<taskdef name="sahidelete" classname="in.co.sahi.ant.DAntDelete" classpath="lib/ant-sahi.jar"/>
<target name="set_timestamp">
<tstamp>
<format property="ts" pattern="yyyy_MM_dd__HH_mm_ss" locale="en, IN"/>
</tstamp>
</target>
<target name="set_properties_common" depends="set_timestamp">
<property name="scriptDir" value="D:/dev/SahiPro/userdata/scripts/"/>
<property name="masterhost" value="192.168.1.30"/>
<property name="masterport" value="9999"/>
</target>
<target name="set_properties_ie" depends="set_properties_common">
<property name="scriptName" value="sahitests/ddcsv/test.dd.csv"/>
<property name="browser" value="ie"/>
<property name="startWith" value="BROWSER"/>
<property name="sendemail" value="true"/>
<property name="emailtrigger" value="success,failure"/>
<property name="emailproperties" value="D:\dev\SahiPro\userdata\config\email.properties"/>
<property name="sendemailForSubSuite" value="false"/>
<property name="sendemailperiodically" value="true"/>
<property name="sendemailperiodicallytime" value="30"/>
<property name="emailPasswordHidden" value="true"/>
<property name="baseURL" value="http://sahitest.com/demo/training/"/>
<property name="failedSuiteName" value="test_failed_${browser}.dd.csv"/>
<property name="failedSuite" value="sahitests/ddcsv/${failedSuiteName}"/>
<property name="threads" value="5"/>
<property name="abortedRetryCount" value="0"/>
<property name="failureRetryCount" value="0"/>
<property name="isAvoidSkipping" value="false"/>
<property name="isSyncConfig" value="false"/>
<property name="isAutohealEnabled" value="false"/>
<property name="showPeriodicSummary" value="true"/>
<property name="jsCodeCoverage" value="false"/>
<property name="configPath" value=""/>
<property name="suiteTimeOut" value="0.0"/>
</target>
<target name="drundiffmasterie" depends="set_properties_ie, set_timestamp">
<!-- Sync suite to Master staging folder -->
<sahisync originFolder="${scriptDir}" destFolder="temp/scripts/staging/${ts}_${browser}" ignorePattern=".*(svn|copied).*" suitePath="${scriptDir}${scriptName}" csvSeparator="," scriptExtensions="sah;sahi;js;ar.csv" scenarioExtensions=".s.csv;xls;xlsx" javaDir="java" exposedJavaClasses="exposed_classes.txt"
isSyncConfig="${isSyncConfig}" isAutohealEnabled="${isAutohealEnabled}" configPath="${configPath}">
<node host="${masterhost}" port="${masterport}"/>
</sahisync>
<sahid suite="${scriptName}"
sendEmail="${sendemail}"
emailtrigger="${emailtrigger}"
emailProperties="${emailproperties}"
sendEmailForSubSuite="${sendemailForSubSuite}"
sendEmailPeriodically="${sendemailperiodically}"
sendEmailPeriodicallyTime="${sendemailperiodicallytime}"
emailPasswordHidden="${emailPasswordHidden}"
baseurl="${baseURL}"
sahihost="${masterhost}"
sahiport="${masterport}"
failureproperty="sahi.failed.${browser}"
failedSuiteName="${failedSuiteName}"
haltonfailure="false"
browsertype="${browser}"
startWith="${startWith}"
scriptsPathMaster="temp/scripts/staging/${ts}_${browser}/"
scriptsPathInitiator="${scriptDir}"
threads="${threads}"
abortedRetryCount="${abortedRetryCount}"
failureRetryCount="${failureRetryCount}"
isAvoidSkipping="${isAvoidSkipping}"
isAutohealEnabled="${isAutohealEnabled}"
isSyncConfig="${isSyncConfig}"
jsCodeCoverage="${jsCodeCoverage}"
showPeriodicSummary="${showPeriodicSummary}"
suiteTimeOut="${suiteTimeOut}"
isDifferentMaster="true"
ignorePattern=".*(svn|copied).*"
tags="(user||admin)&&medium"
userDefinedId="IETestRun1">
<!-- Custom fields - add, edit or remove as required -->
<customfield key="user" value="test"/>
<customfield key="mask_password" value="secret"/>
<!-- Scripts will be distributed across all the nodes. The nodes may or may not include the Master machine -->
<node host="localhost" port="9999"/>
<node host="192.168.1.29" port="9999"/>
<!-- Offline reports -->
<report type="xml" logdir="logs/temp/xml/${ts}"/>
<report type="html" logdir="logs/temp/html/${ts}"/>
</sahid>
<!-- Delete suite from Master staging folder -->
<sahidelete host="${masterhost}"
port="${masterport}"
filePath="temp/scripts/staging/${ts}_${browser}" isSyncConfig="${isSyncConfig}" isAutohealEnabled="${isAutohealEnabled}" scriptDir="${scriptDir}">
</sahidelete>
<!-- Pull the logs from the Master onto the Initiator machine -->
<sahipull sourceHost="192.168.1.30" sourcePort="9999" originFolder="logs/temp/xml/${ts}" destFolder="logs/xml" ignorePattern=".*(svn|copied).*"/>
<sahipull sourceHost="192.168.1.30" sourcePort="9999" originFolder="logs/temp/html/${ts}" destFolder="D:\temp\html" ignorePattern=".*(svn|copied).*"/>
<antcall target="failsahiie"/>
</target>
<target name="failsahiie" depends="set_properties_ie" if="sahi.failed.${browser}">
<fail message="Sahi tests failed on browser ${browser}!"/>
</target>
</project>
danger
NOTE:
The above XML content is for illustration purposes only. Use the Editor UI to generate the ANT xml content and create an xml with that content.
Let us look at the important attributes used in the ANT xml target (specified in bold above).
Attributes and their description
info
taskdef classpath is relative to where ant is run from.
scriptDir | Specifies the path to the scripts folder on the Initiator machine. This can be an absolute path or a path relative to where Ant is run from |
masterhost | Hostname of the different Master server where Sahi is running (Can be IP as well) |
masterport | Port on which Sahi is running |
scriptName | Relative path to the script/suite/data driven suite. It is relative to scriptDir. |
browser | The browser on which the suite file plays back |
baseurl | Specifies URL which is the starting URL for all the scripts in the suite |
threads | Number of simultaneous browser instances on which sahi tests will be run. |
showPeriodicSummary | Takes "true" or "false". If "true", a periodic summary of script status is logged in the Ant Console. |
isAutohealEnabled | Takes "true" or "false". If "true", allows scripts to pick element using Sahi auto intelligence when element provided in script is not found. Refer Autoheal section for more details. |
sendemail | Takes "true" or "false". If "true", Sahi sends an email summarizing the playback. |
emailtrigger | Takes "success" or "failure" or "success,failure". Triggers email in case of SUCCESS, FAILURE and both cases respectively. |
emailproperties | Path to the properties file that contains details about the mail viz. information about the sender, receiver, host, port, subject, content etc. Path can be the absolute path or relative to where this ant target is run from. |
sendemailperiodically | Takes "true" or "false". If "true", Sahi will send emails periodically till the suite run is complete. |
sendemailperiodicallytime | Specifies the interval in minutes at which periodic emails are to be sent. |
failedSuiteName | Name of the failed suite. It is of the form <suitename>_failed_<browser>.suite . |
failedsuite | Relative path to the failed suite. It is relative to scriptDir. |
tags | Tags should be specified only for dd.csv and .csv suites. Tags are specified so that it is easy to choose which scripts/testcases to run. eg. in the target above, all the scripts which have 'medium' tag and 'admin' or 'user' (or both) tag will be run. |
userdefinedid | The unique id that the user can pass to differentiate a suite from others. This is an optional attribute. |
node | Each node attribute specifies a machine on which the tests should run. Add as many node entries as there are machines to run. The nodes may or may not include the Master machine. If the Master machine is not included, scripts will not be run on the Master . There can be 1 or more nodes.
|
customfield | Custom fields can be passed to the scripts using the customfield attribute. More than one custom field can be passed, by specifying additional customfield entries. Replace the custom field keys and values as appropriate. This is an optional attribute. |
ant -f demo.xml
Ability to register Nodes externally (from Sahi Pro V6.1.0)
It is now possible to register a new Node for a currently running distributed run.Using registerNodes.bat/registerNodes.sh
- Open a command prompt and cd to sahi/userdata/bin (or click on the "Bin" link on the Sahi Dashboard)
- Run register_nodes.bat to see the syntax
D:\sahi_pro\userdata\bin>register_nodes.bat -- Usage: register_nodes.bat <extnodes> <userDefinedId> <suiteId> - extnodes is a comma separated string of host:port combos, example: "machine1:9999,machine2:9999". If multiple nodes are specified, enclose them in double quotes. - userDefinedId is the User defined Id specified while running the original suite - suiteId is the SuiteId of the running suite, and can be found from Suite Info section in the Suite Report log - NOTE: Only one of suiteId or userDefinedId is required. If both suiteId and userDefinedId are passed, suiteId will be used to identify the running suite. -- Example: 1. Registering one machine using userDefinedId (say abc1234). register_nodes.bat machine1:9999 abc1234 2. Registering more than one machine using userDefinedId. register_nodes.bat "machine1:9999,machine2:9999" abc1234 3. Registering one machine using suiteId (say sahi_a0ba301605a8f04cb10881e0ddcd96f9dfbd). NOTE: Some value HAS to be passed for the second parameter - userDefinedId. Pass "". register_nodes.bat machine1:9999 "" sahi_a0ba301605a8f04cb10881e0ddcd96f9dfbd 4. Registering more than one machine using suiteId. NOTE: Some value HAS to be passed for the second parameter - userDefinedId. Pass "". register_nodes.bat "machine1:9999,machine2:9999" "" sahi_a0ba301605a8f04cb10881e0ddcd96f9dfbd -- D:\sahi_pro\userdata\bin>
-
Nodes can be registered for a currently running suite. The suite can be specified either using userDefinedId or suiteId. If both are specified, suiteId will be used. suiteId for the current run can be found from the
Suite Info
section of the Suite report logs.-
To register using userDefinedId, use something like the following
register_nodes.bat "192.168.1.100:9999,192.168.1.101:9999" myUserDefinedId
info Multiple nodes can be specified using comma separator. If more than one node is specified, use double quotes for the nodes.Note that these values are indicative. Please use your own values. -
To register using suiteId, use something like the following
register_nodes.bat "192.168.1.100:9999,192.168.1.101:9999" "" sahi_a0ba301605a8f04cb10881e0ddcd96f9dfbd
infoNote that these values are indicative. Please use your own values.- Pass "" as the second parameter for userDefinedId.
- Multiple nodes can be specified using comma separator. If more than one node is specified, use double quotes for the nodes.
-
To register using userDefinedId, use something like the following
registernodes.xml
in your <SAHI_INSTALLATION_FOLDER>
.
You can now run the default ANT target in the xml file as
ant -f registernodes.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
/**
* Copyright Tyto Software Pvt. Ltd.
*/
-->
<project name="demo" default="register">
<taskdef name="sahinodeclient" classname="in.co.sahi.ant.DAntNodeClient" classpath="lib/ant-sahi.jar"/>
<!-- Use suiteId or userDefinedId. If both are specified, suiteId would be used. -->
<target name="register">
<sahinodeclient
sahihost="localhost"
sahiport="9999"
userDefinedId="myUserDefinedId">
<node host="192.168.1.100" port="9999"/>
<node host="192.168.1.101" port="9999"/>
</sahinodeclient>
</target>
</project>
Note that all these values are indicative.
Attributes and their description
info
taskdef classpath is relative to where ant is run from.
sahihost | Hostname of the Master where Sahi is running (Can be IP as well). |
sahiport | Port on which Sahi is running |
userDefinedId | UserDefinedId specified while running the original suite |
suiteId | SuiteId of the running suite. Get this value from the Suite Info section of the Suite Report logs |
node | Specify one entry each for every node that you want to register. |
info
Specify either userDefinedId or suiteId. If both are specified, suiteId will be used.
Command to execute the above ANT target
ant -f registernodes.xml
Killing a running script/suite
warning
WARNING: Killing a suite (or all running suites) in the middle of a run is not a routine task. You would kill a suite only if something went wrong and you wish to stop the suite execution.
Stop All
from the Editor can be used to kill all running scripts/suites.
This is now possible through an ANT target as well.
The ANT target gives the ability to kill a specific running suite or kill all the running suites.
Copy the following content to an empty file and save the file as an xml, say
killall.xml
in your <SAHI_INSTALLATION_FOLDER>
.
You can now run the default ANT target in the xml file as
ant -f killall.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
/**
* Copyright Tyto Software Pvt. Ltd.
*/
-->
<project name="demo" default="kill">
<taskdef name="sahikill" classname="in.co.sahi.ant.DKillTask" classpath="lib/ant-sahi.jar"/>
<!-- This target will kill the running suite(s) on sahihost. sahihost can be other than localhost as well. -->
<!-- If neither suiteId nor userDefinedId is specified, all running suites on this Master will be killed. -->
<!-- If you wish to kill a specific suite, use suiteId or userDefinedId. If both are specified, suiteId would be used. -->
<target name="kill">
<sahikill
sahihost="localhost"
sahiport="9999">
</sahikill>
</target>
</project>
Attributes and their description
info
taskdef classpath is relative to where ant is run from.
sahihost | Hostname of the Master where Sahi is running (Can be IP as well). |
sahiport | Port on which Sahi is running |
userDefinedId | UserDefinedId specified while running the original suite |
suiteId | SuiteId of the running suite. Get this value from the Suite Info section of the Suite Report logs |
info
Command to execute the above ANT target
- If neither suiteId nor userDefinedId is specified, all running suites on this Master will be killed.
- If you wish to kill a specific suite, use suiteId or userDefinedId. If both are specified, suiteId would be used.
ant -f killall.xml