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 Available Modes

To get the list of available modes, you can use the following request URL. The response is an array with names of all available modes.

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 is an array with names of all browsers.

Request URL: Response:

Get All Available Android Devices/Emulators

To get the list of Android devices available to Sahi, you can use the following request URL. The response is a list of Android Devices/Emulators in JSON format OR null (in case of Android automation is not supported).

Name Description Value
refresh If set to true, devices list will be refreshed.

Request URL: Response:
info NOTE: Provide any of the key (name, displayName, deviceName, deviceId) as 'AndroidDevice' in the URL of running script/suite.

Get All Available iOS Devices/Simulators

To get the list of Android devices available to Sahi, you can use the following request URL. The response is a list of iOS Devices/Simulators in JSON format OR null (in case of iOS automation is not supported).

Name Description Value
refresh If set to true, devices list will be refreshed.

Request URL: Response:
info NOTE: Provide any of the key (name, displayName, deviceName, deviceId, deviceParams) as 'iOSDevice' in the URL of running script/suite.

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%2Fsahitests%2Fsmall.suite
	&startWith=BROWSER
	&browserType=chrome
	&baseURL=http%3A%2F%2Fsahitest.com%2Fdemo%2F
	&androidDevice=XXXX
	&iOSDevice=XXXX
	&threads=5
	&isSingleSessionS=false
	&jsCodeCoverage=false
	&abortedRetryCount=0
	&failureRetryCount=0
	&logsInfo=
	&tags=
	&userDefinedId=2June2015__12_1_36_338
	&suiteTimeOut=0.0
	&isAutoHealEnabled=false
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
startWith Specify the start mode. Example: BROWSER
browserType Browser on which scripts will be executed. Example: chrome
suite Example : C:/sahi_pro/userdata/scripts/sahitests/small.suite
baseURL Sets a default Start URL for scripts. Example: http://sahitest.com/demo/
AndroidDevice Android device in which script will be executed.
iOSDevice iOS device in which script will be executed.
jsCodeCoverage If "true", collect the JS Code Coverage. Example: false
abortedRetryCount Specify the retry count for aborted script.
failureRetryCount Specify the retry count for failed script.
logsInfo logsInfo format is type:filePath,type2:filePath2 [Example: html:D:/logs/html,xml:D:/logs/xml ]
tags tags seperated by '&&', '||', '!' operators. [Example: (user||admin)&&medium ]
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.
Time Out (Minutes) Specify the time out in minutes for script.
Enable autohealing of elements if not found.
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 seven types of status, INITIAL, RUNNING, SUCCESS, FAILURE, ABORTED, SKIPPED and USER_ABORTED. 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
	&host=localhost
	&port=9999
	&scriptsPathMaster=C%3A%2Fsahi_pro%2Fuserdata%2Fscripts
	&suite=sahitests%2Fsmall.suite
	&browserType=chrome
	&baseURL=http%3A%2F%2Fsahitest.com%2Fdemo%2F
	&androidDevice=XXXX
	&iOSDevice=XXXX
	&tags=
	&threads=5
	&jsCodeCoverage=false
	&abortedRetryCount=0
	&failureRetryCount=0
	&logsInfo=
	&nodes=node1%3A9999%2Cnode2%3A9999
	&userDefinedId=2June2015__12_1_36_338
	&suiteTimeOut=0.0
	&isAutoHealEnabled=false
Name Description Value
suite The suite should be relative to scriptsPathMaster. Example : sahitests/small.suite
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
startWith Specify the start mode. Example: BROWSER
threads Number of simultaneous browser instances that can be executed. Example: 3
browserType Browser on which scripts will be executed. Example: chrome
baseURL Sets a default Start URL for scripts. Example: http://sahitest.com/demo/
AndroidDevice Android device in which script will be executed.
iOSDevice iOS device in which script will be executed.
jsCodeCoverage If "true", collect the JS Code Coverage. Example: false
abortedRetryCount Specify the retry count for aborted script.
failureRetryCount Specify the retry count for failed script.
logsInfo logsInfo format is type:filePath,type2:filePath2 [Example: html:D:/logs/html,xml:D:/logs/xml ]
tags tags seperated by '&&', '||', '!' operators. [Example: (user||admin)&&medium ]
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.
Time Out (Minutes) Specify the time out in minutes for script.
Enable autohealing of elements if not found.
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
		&extNodes=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:

Load Testing

To execute load tests on your application, you can use a URL like this:

http://localhost:9999/_s_/dyn/SahiEndPoint_runDistributedLoad?a=a
	&scriptsPathMaster=C%3A%2FUsers%2FTyto2Fsahi_proP112%2Fuserdata%2Fscripts
	&suitePath=sahitests%2Fload%2Fsubject.sah
	&noisepath=sahitests%2Fload%2Fnoise.sah
	&noiseBrowserType=chromeHL
	&nodes=localhost%3A9999
	&port=9999
	&startWith=BROWSER
	&browserType=firefox
	&min=1
	&incrementBy=2
	&host=localhost
	&isDifferentMasterS=null
	&max=9
	&ignorePattern=.*%28svn%7Ccopied%29.*
	&logsInfo=html
	&baseURL=http%3A%2F%2Fsahitest.com%2Fdemo%2Ftraining%2F
	&subjectRepeatCount=3
	&interval=5
Name Description Value
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
noise The noise script should be relative to scriptsPathMaster. Example : sahitests/load/noise.sah
subject The subject script should be relative to scriptsPathMaster. Example : sahitests/load/subject.sah
noiseBrowserType The browser on which the noise script is run (default chromeHL)
nodes Comma separated value of node:port combinations. Example: node1:9999,node2:9999
startWith Specify the start mode. Example: BROWSER
browserType Browser on which scripts will be executed. Example: chrome
baseURL Sets a default Start URL for scripts. Example: http://sahitest.com/demo/
minThread The minimum number of noise browsers to run initially
maxThread The maximum number of noise browsers to run finally
increment The number of noise browsers to be run incrementally after the specified interval
interval The interval after which to increment the noise browsers by
subjectRepeatCount Number of times the subject script should be run at every noise level. It is good to run it more than 1 time to average out any random behaviour.
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: