-code -->

Playback on Desktop

abstract This section describes various ways of playing back Sahi scripts.

Playback via Sahi Controller

To playback via Controller, go to the Playback tab, choose the script to play and click "Play". As the script executes, Sahi will display the steps executed and also log them into a database. You can view the logs by clicking on "Logs" link at the bottom of the Controller.

Distributed Runs - More Information

The following information is applicable for distributed runs on the same Master as well as on a different Master. It is applicable irrespective of how the run was executed - Editor, ANT xml, batch file or shell script, etc.

Smart zip (from Sahi Pro V6.1.0)

In versions prior to Sahi Pro V6.1.0, the entire scripts folder would get synced to different nodes. If the scripts folder was huge, this would take time and also cause memory issues at times. As of Sahi Pro V6.1.0, we only sync the scripts necessary to execute a run. Refer to _resource API on how to include resources used in your scripts.

Distribute scripts in rotation (from Sahi Pro V6.1.0)

Prior to Sahi Pro V6.1.0, if there were multiple nodes, priority would always be given to the first node in the Nodes list, and would decrease as we go to the end of the nodes list. Thus you would always find that more scripts were run on the initial nodes than on the nodes at the end of the list. As of this release, scripts are assigned to nodes one by one so long as capacity is available on the node. So scripts get rotated and the distribution becomes more even across Nodes.

For example, assume that there are 4 nodes, the capacity of Chrome browser on each node is 5, and that there are 50 scripts to distribute. Prior to Sahi Pro V6.1.0 - The first 5 scripts will go to Node 1. If at the time of assigning the 6th script, any of the earlier 5 scripts gets completed, the 6th script would also go to Node 1 since it has free capacity. As of Sahi Pro V6.1.0 - The first script will go to Node 1, the second to Node 2, and so on.

Scripts rotation can be switched off by setting the flag drun.run_scripts_in_rotation to false in userdata.properties. By default, this value is true.

Nodes monitoring (from Sahi Pro V6.1.0)

From Sahi Pro V6.1.0, the nodes participating in a distributed run are now monitored internally. Node monitoring can be turned off by setting the flag drun.nodes_monitoring_enabled to false in userdata.properties. By default, this value is true.

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
  1. Open a command prompt and cd to sahi/userdata/bin (or click on the "Bin" link on the Sahi Dashboard)
  2. 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>
  3. 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
      info
      • 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.
      Note that these values are indicative. Please use your own values.
Using an ANT target Copy the following content to an empty file and save the file as an xml, say 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.
sahihostHostname of the Master where Sahi is running (Can be IP as well).
sahiportPort on which Sahi is running
userDefinedIdUserDefinedId specified while running the original suite
suiteIdSuiteId of the running suite. Get this value from the Suite Info section of the Suite Report logs
nodeSpecify 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.
sahihostHostname of the Master where Sahi is running (Can be IP as well).
sahiportPort on which Sahi is running
userDefinedIdUserDefinedId specified while running the original suite
suiteIdSuiteId of the running suite. Get this value from the Suite Info section of the Suite Report logs
info
  • 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.
Command to execute the above ANT target
ant -f killall.xml


Changes in staging and copied folders behaviour (from Sahi Pro v6.1.0)

In a distributed run, scripts get copied to Nodes in temp/scripts/copied directory, under timestamped folders. At the end of the run, these timestamped folders get deleted. Likewise, in a distributed run on a different Master, scripts first get synced to a timestamped folder inside temp/scripts/staging directory of the Master. At the end of the run, these timestamped folders get deleted.

These changes have been done to support sharing of a Master or Node between different distributed runs at the same time.

If for debugging purposes, one wants the staging and copied folders to remain undeleted, one can set the flag drun.debugging_enabled to true in userdata.properties. Refer to instructions in sahi.properties. Use with extreme caution. By default, this value is false.

Experimental feature: Ability to share Master and Nodes between different distributed runs (from Sahi Pro v6.1.0)

It is possible now to use a machine as Master for different distributed runs in parallel. The same applies for Nodes as well. This could be useful in a Test Lab kind of environment where a powerful machine can serve as the Master for multiple distributed runs.

Periodic Summary during Script Playback

By default, a periodic summary of the script execution is shown when running the scripts from Script Editor, Ant, Testrunner, Drun and Drun Diff Master. Whenever there is a change in the status of script, it will be printed in the Console or shown as an Editor notification.

A sample periodic summary on Ant, Testrunner, Drun and Drun Diff Master Console will look like the following:

May 30, 2016 04:31:20 PM STARTED: label.sah BROWSER: chrome May 30, 2016 04:31:20 PM STARTED: screenSize.sah BROWSER: chrome May 30, 2016 04:31:25 PM PASSED: screenSize.sah BROWSER: chrome May 30, 2016 04:31:25 PM Testcases: 0/0, Scripts: 1/2 BROWSER: chrome May 30, 2016 04:31:39 PM FAILED: label.sah BROWSER: chrome May 30, 2016 04:31:39 PM Testcases: 0/0, Scripts: 1/2 BROWSER: chrome


There are two kind of messages that come up in the console.
[timestamp] [status: scriptname] [BROWSER: browsername]
[timestamp] [Testcases: passed/total_ran] [Scripts: passed/total_ran] [BROWSER: browsername]
timestampTime Stamp of the Initiator machine.
status: scriptnameStatus of the script (STARTED, PASSED, FAILED) followed by script name.
Testcases: passed / total_ranTotal number of testcases passed / Total number of testcases executed.
Scripts: passed / total_ranTotal number of scripts passed / Total number of scripts executed.
BROWSER: browsernameBrowser on which the script was executed.
When playing back the scripts from the Editor, these messages appear as notifications on the bottom right corner of the Editor. The message will look like as below
info NOTE: The Initiator and the Master machine should be on Sahi Pro v6.3.0 for this to work. We would recommend you to use Sahi Pro v6.3.0 on the slave machines as well.