Sahi Pro - UserDefinedId
It is possible for users to pass in a unique id of their own to differentiate a suite from another. This is referred to as UserDefinedId.
Passing UserDefinedId
You can pass/set the UserDefinedId in a variety of ways.
-
UserDefinedId can be passed from testrunner.bat as follows.
-
Edit testrunner.bat.
Change the following line
java -cp %SAHI_HOME%\lib\ant-sahi.jar net.sf.sahi.test.TestRunner %CUSTOM_FIELDS% -test %SCRIPTS_PATH%/%1 -browserType %3 -logsInfo "%LOGS_INFO%" -baseURL "%START_URL%" -host localhost -port 9999 -threads %THREADS% -useSingleSession %SINGLE_SESSION% -failedScriptsSuite %FAILED_SCRIPTS_SUITE% -tags %4
to
java -cp %SAHI_HOME%\lib\ant-sahi.jar net.sf.sahi.test.TestRunner %CUSTOM_FIELDS% -userDefinedId "specify your UserDefinedId here" -test %SCRIPTS_PATH%/%1 -browserType %3 -logsInfo "%LOGS_INFO%" -baseURL "%START_URL%" -host localhost -port 9999 -threads %THREADS% -useSingleSession %SINGLE_SESSION% -failedScriptsSuite %FAILED_SCRIPTS_SUITE% -tags %4
Replace "specify your UserDefinedId here" with your UserDefinedId.
-
Edit testrunner.bat.
-
If you are using ANT to run the script, you can specify the UserDefinedId in the
<sahi>
target.
Example:
<target name="runfftests"> <sahi suite="../userdata/scripts/demo/demo.suite" browserType="firefox11" baseurl="http://${urlbase}/demo/" sahihost="localhost" sahiport="9999" failureproperty="sahi.failed" haltonfailure="false" userDefinedId="sahi.co.in_firefox_english" threads="6"> <customfield key="language" value="english"/> <customfield key="failedScriptsSuite" value="../userdata/scripts/failed_scripts.suite"/> <report type="html"/> </sahi> <antcall target="retryfailed"/> </target>
-
There are instances when the UserDefinedId can be known only at runtime. In such cases, you can set it from inside the script as follows.
ScriptRunner.getSession().getSuiteInfo().setUserDefinedId("test");
UserDefinedId not visible in V5.x.y by default
By default, UserDefinedId is not displayed in the list of Suite Reports.To display it, please do the following steps.
-
Take a backup of
userdata\config\reports\html\suites_list.xsl
.
-
Edit
userdata\config\reports\html\suites_list.xsl
.
-
Right at the start, you will see two XSL params
showUserDefinedId
andshowBaseUrl
.
<xsl:param name="showUserDefinedId" select="'false'" /> <xsl:param name="showBaseUrl" select="'true'" />
-
Set showUserDefinedId to 'true'. The line will look like:
<xsl:param name="showUserDefinedId" select="'true'" />
info NOTE that true is inside single quotes inside the double quotes.
-
Set showBaseUrl as "'true'" or "'false'" based on whether you want to display the Base Url (Start Url) or not.
-
Right at the start, you will see two XSL params