Sahi Launcher (sahi.jar)

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


Configuration

The sahi.xml file allows pre-configuring the launcher with some default values:


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.


Requirements

  • 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 ../.. ..


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

  • The utility tool to enable proxying on he 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"




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