- Open the Sahi Dashboard and click the link labeled as “Bin”. It will open a command window.
- Use the command “testrunner”. Following screen will appear on windows.
- The example above shows the syntax for running:
- 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’.
- The second example demonstrates running a Sahi script with the given start URL in IE.
- The third example runs the same script but in both firefox and IE using this command.
- 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 IE. The tags are specified only if the input suite is a .csv file.
- 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.
- 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.
- Details about the .csv file:
- 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.
- The image above is from the userdata/scripts/demo/testcases_sample.csv.
- 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.
- 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.
- 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.
- Start URL specifies the URL from where the execution will begin. This can be specified while executing the suite from the command line.
- 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:
var $t = _testcase("TC_1", "Login");
var $t2 = _testcase("TC_2", "Add books");
var $t3 = _testcase("TC_8", "Verify total");
Reports and Summary
- Open the report from the logs by clicking on the suite name that was supplied.
- On clicking the following window will appear (image below):
- It contains the reports on the Sahi scripts that were executed as part of the suite.
- Click on the names of the scripts in the bottom table to get detailed results for the script.
- 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).
- Test cases report for all the cases can be viewed using the menu at the top by clicking on the ‘Test Cases Report’ link.
- 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.
- 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.
- The description in the second table is shown as provided in the Sahi script.
- 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:
- 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:
- 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: