Sahi Launcher (sahi.jar)

The Sahi launcher allows interfacing with Sahi 3 (.sah) scripts.
It has been tested with Sahi v3.


NOTE: see also the documentation about Sahi 3.5, Sahi 4.0 and Sahi 6.0 launchers.

Configuration

The sahi.xml file is just a template and must NOT be edited. It's used by the system to build dynamically the form that the user will be able to fill in from the GUI when creating a custom execution configuration.


Parameter Description
General
Test root path This must indicate where are located all the .sah scripts.
This is a root path. Each test in XStudio has a canonical path that will be appended to this path.
This path MUST not include an ending slash.

Default value is: Y:/Externals/sahi/userdata/scripts
Sahi
Java install path This must indicate the path to the java install.

Default value is: C:/Program Files/Java/jdk1.6.0_17
Sahi install path This must indicate where is installed Sahi on the host.

Default value is: C:/tools/sahi-3
Url This must indicate the base URL of the tested website.

Default value is: http://www.google.com
Browser This must indicate which browser to use to run the tests.
There are choices between:
  • Firefox
  • Internet Explorer 6 and 7
  • Internet Explorer 8
  • Chrome
  • Safari
  • Opera

Default value is: Firefox

Then, there are one section for each browser type.
Only one will be used depending on what has been chosen in the Browser setting.

Firefox
Executable path This must indicate the path to the browser executable.

Default value is: C:/Program Files/Mozilla Firefox/firefox.exe
Process name This must indicate the process name so that the system can kill it if necessary.

Default value is: firefox.exe
Option This must indicate if some options need to be passed to the browser.

Default value is: -profile 'Y:/externals/sahi/userdata/browser/ff/profiles/sahi(dollar)threadNo' -no-remote
Proxy enabling tool Utility to run before starting the browser so that proxy is activated.

Default value is: <empty>
Proxy disabling tool Utility to run after closing the browser so that proxy is disabled.

Default value is: <empty>
Internet Explorer 6 and 7
Executable path This must indicate the path to the browser executable.

Default value is: C:/Program Files/Internet Explorer/IEXPLORE.EXE
Process name This must indicate the process name so that the system can kill it if necessary.

Default value is: iexplore.exe
Option This must indicate if some options need to be passed to the browser.

Default value is: <empty>
Proxy enabling tool Utility to run before starting the browser so that proxy is activated.

Default value is: Y:/Externals/sahi/tools/toggle_IE_proxy.exe enable
Proxy disabling tool Utility to run after closing the browser so that proxy is disabled.

Default value is: Y:/Externals/sahi/tools/toggle_IE_proxy.exe disable
Internet Explorer 8
Executable path This must indicate the path to the browser executable.

Default value is: C:/Program Files/Internet Explorer/IEXPLORE.EXE
Process name This must indicate the process name so that the system can kill it if necessary.

Default value is: iexplore.exe
Option This must indicate if some options need to be passed to the browser.

Default value is: -noframemerging
Proxy enabling tool Utility to run before starting the browser so that proxy is activated.

Default value is: Y:/Externals/sahi/tools/toggle_IE_proxy.exe enable
Proxy disabling tool Utility to run after closing the browser so that proxy is disabled.

Default value is: Y:/Externals/sahi/tools/toggle_IE_proxy.exe disable
Chrome
Executable path This must indicate the path to the browser executable.

Default value is: C:/Documents and Settings/eric/Local Settings/Application Data/Google/Chrome/Application/chrome.exe
Process name This must indicate the process name so that the system can kill it if necessary.

Default value is: chrome.exe
Option This must indicate if some options need to be passed to the browser.

Default value is: --user-data-dir=(dollar)userDir/browser/chrome/profiles/sahi(dollar)threadNo --proxy-server=localhost:9999 --disable-popup-blocking
Proxy enabling tool Utility to run before starting the browser so that proxy is activated.

Default value is: <empty>
Proxy disabling tool Utility to run after closing the browser so that proxy is disabled.

Default value is: <empty>
Safari
Executable path This must indicate the path to the browser executable.

Default value is: C:/Program Files/Safari/Safari.exe
Process name This must indicate the process name so that the system can kill it if necessary.

Default value is: Safari.exe
Option This must indicate if some options need to be passed to the browser.

Default value is: <empty>
Proxy enabling tool Utility to run before starting the browser so that proxy is activated.

Default value is: Y:/Externals/sahi/tools/toggle_IE_proxy.exe enable
Proxy disabling tool Utility to run after closing the browser so that proxy is disabled.

Default value is: Y:/Externals/sahi/tools/toggle_IE_proxy.exe disable
Opera
Executable path This must indicate the path to the browser executable.

Default value is: C:/Program Files/Opera/opera.exe
Process name This must indicate the process name so that the system can kill it if necessary.

Default value is: opera.exe
Option This must indicate if some options need to be passed to the browser.

Default value is: <empty>
Proxy enabling tool Utility to run before starting the browser so that proxy is activated.

Default value is: Y:/Externals/sahi/tools/toggle_IE_proxy.exe enable
Proxy disabling tool Utility to run after closing the browser so that proxy is disabled.

Default value is: Y:/Externals/sahi/tools/toggle_IE_proxy.exe disable


These values can be changed while creating the campaign session from XStudio.


Note about file path parameters:

Any parameter referring to a file or folder path (for instance Test root path) can be provided either using \ separator (if the tests are going to be executed on a Windows agent) or / separator (if the tests are going to be executed on a linux or MacOSX agent).

On windows, if you provide a path containing a, OS-localizable folder such as C:\Program Files, always prefer the English version (i.e. NOT C:\Programmes if you're using a french-localized Windows) or the corresponding native environment variable (i.e. %PROGRAMFILES%).




Process

  • Each test in XStudio must have his dedicated .sah script. The name of the script MUST be equal to the name of the test.

  • The sahi proxy server is launched by the launcher using this syntax:

    "<javaInstallPath>/bin/java.exe" -cp ../../lib/sahi.jar;../../extlib/rhino/js.jar;
    ../../extlib/apc/commons-codec-1.3.jar
    net.sf.sahi.Proxy ../.. ..


    or with Sahi Pro:

    "<javaInstallPath>/bin/java.exe" -cp ../../lib/sahi.jar;../../extlib/rhino/js.jar;
    ../../extlib/apc/commons-codec-1.3.jar;../../extlib/db/h2-1.2.134.jar;
    ../../extlib/license/truelicense.jar;../../extlib/license/truexml.jar
    net.sf.sahi.Proxy ../.. ..


    and from the working directory "<sahiInstallPath>/userdata/bin"

  • The utility tool to enable proxying on the browser is launched.

  • The sahi test runner is launched by the launcher using this syntax:

    "<javaInstallPath>/bin/java.exe" -cp ../../lib/ant-sahi.jar net.sf.sahi.test.TestRunner
    "<testRootPath>/<testPath>/<testName>.sah" "<browserExePath>" <baseUrl>/<additionalInfo>
    default localhost 9999 3 <processName> "<option>"


    and from the working directory "<sahiInstallPath>/userdata/bin"

  • The utility tool to disable proxying on the browser is launched.



Tutorial: Creating and executing Sahi tests

In this tutorial, we will learn to run some Sahi test scripts.


Prerequisites

Install Sahi in the folder C:\\Program files\\Sahi
We will run one sample test included in the Sahi distribution package.



Create a dedicated category for Sahi tests and create a test

  • create a category Sahi associated to the launcher sahi.jar
  • under this category, create (somewhere in the tree) a test with name sahi_demo with a canonical path set to demo and the additional info field set to demo/index.htm.



Creating a test campaign

  • create a campaign including only the test sahi_demo
  • create a campaign session specifying in the configuration:
    • Test root path: C:/Program files/Sahi/userdata/scripts
    • Sahi install path: C:/Program Files/Sahi
    • Url: http:/sahi.co.in
  • leave all the other configuration parameter with their default values



Run a campaign session

Run the campaign session


Sahi 3.5 Launcher (sahi35.jar)

The Sahi 3.5 launcher allows interfacing with Sahi 3.5 (.sah) scripts.
It has been tested with Sahi v3.5.


The only difference with the Sahi 3 Launcher is the way to start the tests (because the command line has been slightly modified to support test, browserType, baseUrl and host option).

Process

  • Each test in XStudio must have his dedicated .sah script. The name of the script MUST be equal to the name of the test.

  • The sahi proxy server is launched by the launcher using this syntax:

    "<javaInstallPath>/bin/java.exe" -cp ../../lib/sahi.jar;../../extlib/rhino/js.jar;
    ../../extlib/apc/commons-codec-1.3.jar net.sf.sahi.Proxy ../.. ..


    or with Sahi Pro:

    "<javaInstallPath>/bin/java.exe" -cp ../../lib/sahi.jar;../../extlib/rhino/js.jar;
    ../../extlib/apc/commons-codec-1.3.jar;../../extlib/db/h2-1.2.134.jar;
    ../../extlib/license/truelicense.jar;
    ../../extlib/license/truexml.jar
    net.sf.sahi.Proxy ../.. ..


    and from the working directory "<sahiInstallPath>/userdata/bin"

  • The utility tool to enable proxying on the browser is launched.

  • The sahi test runner is launched by the launcher using this syntax:

    "<javaInstallPath>/bin/java.exe" -cp ../../lib/ant-sahi.jar net.sf.sahi.test.TestRunner
    -test "<testRootPath>/<testPath>/<testName>.sah"
    -browserType "<browserExePath>"
    -baseUrl <baseUrl>/<additionalInfo>
    -host localhost 9999 3 <processName> "<option>"


    and from the working directory "<sahiInstallPath>/userdata/bin"

  • The utility tool to disable proxying on the browser is launched.




Sahi 4.0 Launcher (sahi40.jar)

The Sahi 4.0 launcher allows interfacing with Sahi 4.0 (.sah) scripts.
It has been tested with Sahi v4.0.


The only difference with the Sahi 3.5 Launcher is the results parsing implementation (because the XML output format did change completely).


Sahi 6.0 Launcher (sahi60.jar)

The Sahi 6.0 launcher allows interfacing with Sahi 6.0 (.sah) scripts.
It has been tested with Sahi v6.0.


This launcher is completely different from the other Sahi launchers.
Its configuration is also much simpler.

Configuration

The sahi60.xml file is just a template and must NOT be edited. It's used by the system to build dynamically the form that the user will be able to fill in from the GUI when creating a custom execution configuration.


Parameter Description
General
Test root path This must indicate where are located all the .sah scripts.
This is a root path. Each test in XStudio has a canonical path that will be appended to this path.
This path MUST not include an ending slash.

Default value is: C:/Program Files/sahi/userdata/scripts
Sahi
Sahi install path This must indicate where is installed Sahi on the host.

Default value is: C:/Program Files/sahi
Url This must indicate the base URL of the tested website.

Default value is: http://www.google.com
Browser This must indicate which browser to use to run the tests.
There are choices between:
  • ie
  • xxx
  • yyy
  • zzz

Default value is: Firefox

Process

  • Each test in XStudio must have his dedicated .sah script. The name of the script MUST be equal to the name of the test.

  • If the test case's additional info field is not empty, the sahi test runner is launched by the launcher using this syntax:

    "testrunner" "<testRootPath>/<testPath>/<testName>.sah"
    <url>/<testcaseAdditionalInfo>


    and from the working directory "<sahiInstallPath>/userdata/bin"

  • Else, if the test's additional info field is not empty, the sahi test runner is launched by the launcher using this syntax:

    "testrunner" "<testRootPath>/<testPath>/<testName>.sah"
    <url>/<testAdditionalInfo>


    and from the working directory "<sahiInstallPath>/userdata/bin"

  • Else, the sahi test runner is launched by the launcher using this syntax:

    "testrunner" "<testRootPath>/<testPath>/<testName>.sah"
    <url>


    and from the working directory "<sahiInstallPath>/userdata/bin"





Permissions

WARNING: if you're running your tests on Windows, it may be required to run the tests as administrator.
Having an account with Administrators permissions may even not be enough in some cases (especially if you're using Windows 10) and you may need to disable completely the UAC (User Access Control) on your computer.

To do so:
  • Press the Windows + R key combination
  • Type in regedit
  • Go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System
  • In the right-side pane, look for EnableLUA and set the value 0
  • Close the registry editor
  • Restart your computer



Debug

If your tests are not executed correctly or are reporting only failures, this is very likely because your configuration is incorrect or because you used a wrong naming convention for your tests and test cases.


The best way to quickly find out what's wrong is to look at the traces generated by XStudio (or XAgent).
The traces always include the detailed description of what the launcher performs (command line execution, script execution, API calling etc.) to run a test case. So, if you experiment some problems, the first thing to do is to activate the traces and look at what's happening when you run your tests.


Then, try to execute manually in a cmd box the exact same commands.
This will normally fail the same way.
At this point, you needs to figure out what has to be changed in these commands in order to have them run properly.

When you have something working, compare these commands to what's described in the Process chapter above. This will tell you exactly what you need to change.


Most of the time, this is related to:
  • some incorrect values in some parameters of your configuration,
  • the name of your tests,
  • the name of your test cases,
  • the canonical path of your tests