Sahi V3.5 has a lot of new features. Please watch this video to get started with Sahi V3.5.
Prerequisites
Java 1.5 or above is needed for running Sahi.
Download Sahi
Download Sahi from SourceForge.
You can download any of these: install_sahi_xxx.jar has the installer + Sahi + Source code (recommended) sahi_xxx.zip contains just Sahi sahi-src_xxx.zip contains Sahi + Source code
Install Sahi
Double click on install_sahi_xxx.jar to start the installer. If Java is configured properly, it will launch the installer.
If the installer does not launch, or if the jar file is opened as if it is a zip file, cancel the unzip dialog, open a command prompt, cd to where the file is downloaded, and run java -jar install_sahi_xxx.jar
If you do not wish to use the installer, download the zip files and just unzip sahi_xxx.zip or sahi-src_xxx.zip to a desired location.
Start Sahi Dashboard:
Start Sahi Dashboard by any of the following methods
1) Double click on the desktop shortcut
2) Go to Start -> All Programs -> Sahi -> Start Sahi (Click)
3) Start from the command line.
Windows: – Go to <sahi_root>\userdata\bin and run start_dashboard.bat
Linux – Go to <sahi_root>/userdata/bin and run start_dashboard.sh
The Sahi Dashboard automatically starts the Sahi proxy, and allows launching of browsers without explicitly modifying their proxy settings.
If you wish to explicitly modify the proxy settings for your browser, or if you are using Internet Explorer via a VPN or Datacard (like Tata Photon, Reliance etc.), look here
Recording through Sahi
Bring up the browser of your choice by clicking on any of the browser icons.
Press ALT and double click on the window which you want to record. Sahi’s Controller window will pop up. (If that does not work, press CTRL and ALT keys together and then double click. Make sure popup blockers are turned off. For further trouble shooting have a look at this help link.)
On the Controller, go the the Record tab (would be selected by default).
Give a name for the script, and click ‘Record’
Navigate on your website like you normally would. Most actions on the page will now get recorded.
Add an assertion:
Move the mouse over any html element while pressing Ctrl key. The Accessor field will get populated in the Controller.
Click the “Assert” button to generate assertions for the element. They will appear in the “Evaluate Expression” box.
Click “Test —>” to check that the assertions are true. You can evaluate any javascript using “Evaluate Expression” and “Test —>”. Actions performed via the Controller will not be automatically recorded. Only actions performed directly on the page are automatically recorded. This lets you experiment on the webpage at recording time with out impacting the script.
Once satisfied, click on “Append to Script”. This will add the assertions to the Script.
Click “Stop” to finish recording.
Note that the Controller can be closed and reopened at any time, without disrupting recording.
View the recorded script
The recoded script can be viewed and edited by opening the .sah file in the <sahi_root>\userdata\scripts directory. Sahi scripts are simple text files which use Javascript syntax.
The script can be edited even while recording, so that logical segregation into functions etc. can be done as recording happens.
Playing back
Open the Sahi Controller (CTRL-ALT-DblClick on the page).
Enter the script name in the “File:” field (with the help of the autocompletion feature).
Enter the Start URL of the test. If you had started recording from http://www.google.co.in, use that URL.
Click ‘Set’.
Wait for the page to reload.
Click ‘Play’.
Steps will start executing, and the Controller will be updated accordingly. Once finished, SUCCESS or FAILURE will be displayed at the end of the steps.
Note that the Controller can be closed at any time, without disrupting playback.
View Logs
On the Controller, go to Playback tab and click on “View Logs” link at the bottom right. It will open a window with the results neatly formatted in HTML.
Clicking on a line in the logs will drill down to exact line in script.
You can also view the logs at http://localhost:9999/logs
That is it! You have successfully recorded and played back a Sahi script!
Running a test from command line
With version 3.5, we have removed individual batch files for different browsers and replaced it with testrunner.bat and testrunner.sh