Sahi Pro - Sahi Integration Support

Sahi can be integrated to external tools using some predefined URL calls to Sahi. This document provides a comprehensive step by step list of all URL calls that might be required for a complete integration with Sahi. This document is divided into various sections in order of steps you need to perform while executing a script or suite from an external tool. By modifying the parameters in the page, you can generate a URL for your environment.

Set Sahi Server

By default Sahi server runs on localhost:9999. In case you are using a Sahi server from another machine, modify the host and port accordinglly and click on Update button.

Host: Port:

Get Script Directory

To get the script path specified in the sahi.properties file, you can use the following Request URL. You will get the scripts path as response as shown below.

Request URL:
Response:

Get All Scripts Path In The Given Directory

To get the full path for all the scripts in a given directory, you can use a request URL like this:

http://localhost:9999/_s_/dyn/SahiEndPoint_scriptsList
	?suites=true
	&dir=C%3A%2Fsahi_pro%2Fuserdata%2Fscripts%2F
You will get an array containing the paths of all the scripts in the directory.

Name
Description
Value
suites
If set to true, suite paths will be fetched as well. To ignore suites, set it as false.
dir
Directory Path from which the scripts will be fetched. Example: C:/sahi_pro/userdata/scripts/

Request URL:
Response:

Get All Available Browsers

To get the list of browsers available to Sahi, you can use the following request URL. The response ia an array with names of all browsers.

Request URL:
Response:

Running the Script/Suite

To execute a suite or script, you can use a URL like this:

http://localhost:9999/_s_/dyn/SahiEndPoint_run?a=a
	&suite=C%3A%2Fsahi_pro%2Fuserdata%2Fscripts%2Fdemo%2Fsmall.suite
	&browserType=chrome
	&baseURL=http%3A%2F%2Fsahitest.com%2Fdemo%2F
	&threads=5
	&isSingleSessionS=false
	&logsInfo=
	&userDefinedId=2June2015__12_1_36_338

Name
Description
Value
threads
Number of simultaneous browser instances that can be executed. Example: 3
isSingleSessionS
If "true", runs all scripts in a single browser without closing it between scripts. Example: false
browserType
Browser on which scripts will be executed. Example: chrome
suite
Example : C:/sahi_pro/userdata/scripts/demo/small.suite
baseURL
Sets a default Start URL for scripts. Example: http://sahitest.com/demo/
userDefinedId
The unique id that the user can pass to differentiate a suite from other. You can click on 'Generate Id' button to generate a unique id.


Click on Generate URL button below to generate the request URL as per the values set in the above table. Click on Test button to execute the script.

Request URL:

Check the status of Script/Suite


A script or suite can have four types of status, INITIAL, RUNNING, SUCCESS and FAILURE. To get the current status of a script or suite under execution, you can use a URL like this:

http://localhost:9999/_s_/dyn/SahiEndPoint_status?userDefinedId=2June2015__12_1_36_338


Name
Description
Value
userDefinedId
The unique id that the user can pass to differentiate a suite from other. Example : 2June2015__12_1_36_338

Click on Generate URL button below to get the request URL which will check the status of script/suite identified by the user defined id provided above. Click on Test to check the status.

Request URL:
Response:

Get the Suite logs

To get the logs for a suite, you can use a URL like this:

http://localhost:9999/_s_/dyn/sahiEndPoint_suiteReport
		?userDefinedId=2June2015__12_1_36_338
		&type=xml

Name
Description
Value
userDefinedId
The unique id that the user can pass to differentiate a suite from other. Example: 2June2015__12_1_36_338
type
Response type of URL. This is the type of logs you want. Example: xml

Click on the Generate URL below to get the request URL for the user defined id used above. Click on Test button to get the response which also contains all the script Ids. Click on Get Ids button to get the script Ids from the suite log.

Request URL:
Response:
Script Ids
Get scriptIds from XML :

Get the Script Log

To get the logs for a script, you can use a URL like this:
http://localhost:9999/_s_/dyn/SahiEndPoint_scriptReport?
		id=label_firefox__02Jun2015__12_10_13_955
		&type=xml
The ids are fetched using SahiEndPoint_suiteReport as mentioned in previous section

Name
Description
Value
id
The unique id that differentiate a script from other. Example: label_firefox__02Jun2015__12_10_13_955.
This is autogenerated by Sahi, and needs to be queried first using SahiEndPoint_suiteReport as mentioned in previous section.
type
Response type of URL. This is the type of logs you want. Example: xml

Click on the Generate URL below to get the request URL for the user defined id used above. Click on Test button to get the response, which is the logs for the script run.

Request URL:
Response:

Running the Script/Suite - Distributed Run

To execute a suite or script distributed across nodes, you can use a URL like this:

http://localhost:9999/_s_/dyn/SahiEndPoint_runDistributed?a=a
	&scriptsPathMaster=C%3A%2Fsahi_pro%2Fuserdata%2Fscripts
	&suite=demo%2Fsmall.suite
	&browserType=chrome
	&baseURL=http%3A%2F%2Fsahitest.com%2Fdemo%2F
	&threads=5
	&logsInfo=
	&nodes=node1%3A9999%2Cnode2%3A9999
	&userDefinedId=2June2015__12_1_36_338

Name
Description
Value
threads
Number of simultaneous browser instances that can be executed. Example: 3
browserType
Browser on which scripts will be executed. Example: chrome
scriptsPathMaster
The scriptsPathMaster is the parent folder which contains all script and suite files that need to be run.
Example : C:/sahi_pro/userdata/scripts
suite
The suite should be relative to scriptsPathMaster.
Example : demo/small.suite
baseURL
Sets a default Start URL for scripts. Example: http://sahitest.com/demo/
nodes
Comma separated value of node:port combinations. Example: node1:9999,node2:9999
userDefinedId
The unique id that the user can pass to differentiate a suite from other. You can click on 'Generate Id' button to generate a unique id.


Click on Generate URL button below to generate the request URL as per the values set in the above table. Click on Test button to execute the script.

Request URL:

Register Nodes to a running Suite


Nodes can be added to an already running distributed run.

http://localhost:9999/_s_/dyn/SahiEndPoint_registerNodes
		?userDefinedId=2June2015__12_1_36_338
		&nodes=node1%3A9999%2Cnode2%3A9999

Name
Description
Value
userDefinedId
The unique id that the user can pass to differentiate a suite from other. Example : 2June2015__12_1_36_338
nodes
Comma separated value of node:port combinations. Example: node1:9999,node2:9999

Click on Generate URL button below to get the request URL.
Running the URL will register nodes to suite run associated with the userDefinedId provided above.
Click on Test to run the URL.

Request URL:

Cleanup after executing script


After a script or suite has been executed, cleanup task should be performed to avoid memory leak issues.

http://localhost:9999/_s_/dyn/SahiEndPoint_cleanup?userDefinedId=2June2015__12_1_36_338


Name
Description
Value
userDefinedId
The unique id that the user can pass to differentiate a suite from other. Example : 2June2015__12_1_36_338

Click on Generate URL button below to get the request URL for cleanup of suite.

Request URL:

Kill a running Script/Suite


A suite or script can be kill during execution

http://localhost:9999/_s_/dyn/SahiEndPoint_killAll?userDefinedId=2June2015__12_1_36_338


Name
Description
Value
userDefinedId
The unique id that the user can pass to differentiate a suite from other. Example : 2June2015__12_1_36_338
If left blank, all running suites will be killed.

Click on Generate URL button below to get the request URL for killing a suite.

Request URL: