Sahi Documentation

CSV Files as Suites with Tags

danger DEPRECATED: Use the Scenario Files with tags along with Data Driven Suites instead.
  1. Open the Sahi Dashboard and click the link labeled as "Bin". It will open a command window.

  2. Use the command "testrunner". Following screen will appear on windows.

  3. The example above shows the syntax for running:
    1. The first example executes a suite with its start URL as http://sahi.co.in/demo/ and the browser is specified as Firefox. The path for all the scripts are relative to ?userdata/scripts?.
    2. The second example demonstrates running a Sahi script with the given start URL in IE.
    3. The third example runs the same script but in both firefox and IE using this command.
    4. The fourth example uses a .csv file (described below) to pick up the Sahi scripts to be executed. Further it is provided with the start URL as http://sahi.co.in/demo/ and the browser is specified firefox. The tags are specified only if the input suite is a .csv file.
    5. The logic to select the scripts is specified within the quotes. It can be any logic expression based on the tags provided in the .csv file (see below for details). In this particular example it will select the scripts whose tags contains either ?user? or ?admin? and contains ?medium?. On evaluation this gives the scripts training.sah and clicksTest.sah as the scripts to be executed.
    6. An important thing to note is that since the TC_1 and TC_2 are in the same script, so when the script training.sah will be executed, both the test cases will be evaluated.
  4. Details about the .csv file:


    1. The column header titles should be “Test Case Id”, “Script”, “Tags”, “Start URL” for the respective columns to ensure proper functioning. Rest columns may have different names.
    2. The image above is from the userdata/scripts/sahitests/testcases_sample.csv.
    3. All the items from column A to E are a general listing of test cases. It gives the test cases an ID, description, priority and functionality.
    4. Column F is the name of Sahi script which contains the test script for the particular test case. One script may contain more than one test case. When a script is run, all the test cases in that will be evaluated.
    5. Tags are specified against the scripts and are used to select the scripts based on these tags. Only scripts with specified tags will be executed. However, if two test cases are specified in same script, but have different tags, and the user specified tags matches tags for any test case, the complete script will run, thus evaluating all the test cases within that script.
    6. Start URL specifies the URL from where the execution will begin. This can be specified while executing the suite from the command line.
  5. Run the command as shown in fourth example and proceed to reports at the end of execution.

Demarcating multiple test case boundaries in single script

A single script may flow through multiple testcases. To demarcate testcase boundaries, the _testcase() API is used:

_navigateTo("/demo/training/");

var $t = _testcase("TC_1", "Login");
$t.start();
_setValue(_textbox("user"), "test");
_setValue(_password("password"), "secret");
_click(_submit("Login"));
$t.end();

var $t2 = _testcase("TC_2", "Add books");
$t2.start();
_setValue(_textbox("q"), "2");
_setValue(_textbox("q[1]"), "1");
_setValue(_textbox("q[2]"), "1");
_click(_button("Add"));
$t2.end();

var $t3 = _testcase("TC_8", "Verify total");
$t3.start();
_assertExists(_textbox("total"));
_assert(_isVisible(_textbox("total")));
_assertEqual("1150", _textbox("total").value);
$t3.end();


Reports and Summary

  1. Open the report from the logs by clicking on the suite name that was supplied.
  2. On clicking the following window will appear (image below):
    1. It contains the reports on the Sahi scripts that were executed as part of the suite.
    2. Click on the names of the scripts in the bottom table to get detailed results for the script.
    3. From the menu on the top, test cases summary can be seen on the browser and can be further downloaded as a .csv file (explained later in document).
    4. Test cases report for all the cases can be viewed using the menu at the top by clicking on the ?Test Cases Report? link.

  3. Click on the script name in the bottom table to view the details about the test cases that were the part of the script and their status. The window appears like the image attached below.
    1. The table at the bottom shows the details of the actions taken by Sahi while running the test cases. Clicking on any step opens up the Sahi script.
    2. The description in the second table is shown as provided in the Sahi script.


  4. You can go to a particular line in the script by clicking the code and the browser will open a window with script and the particular line highlighted. In the above image if we click on _click(_submit("Login")); , the following screen will be shown:

  5. The "Test Cases Report Summary" link at the top of the window opens a summary for the run and displays it in a tabular form. This is mostly like the .csv file which was given as the input but with new columns to show the status, description and other details of the run. The image below is for one typical report:

  6. This above report can further be downloaded in a .csv file using the download link at the top of the page labeled as ?Download CSV?. The downloaded file looks like following image for above run: