SourceForge.net Logo

Sahi - Web Automation and Test Tool


Documentation in this directory is not current. Please visit http://sahi.co.in/ for the latest documentation.


Record and Playback

Getting started

Starting Sahi:

Windows:
- Go to <sahi_root>\bin and run sahi.bat
Linux
- Go to <sahi_root>/bin and run sahi.sh
Note that by default Sahi uses port 9999. This can be modified through sahi.properties


Configuring the browser:

    Firefox:
  • Go to Tools > Options > General > Connection Settings >
  • Set to "Manual Proxy Configuration"
  • Set "HTTP Proxy" to "localhost"
  • Set "Port" to "9999". (This setting can be modified through <sahi_root>/config/sahi.properties)
  • Do the same for "SSL Proxy" too, if you wish to record and playbacl https sites
  • Keep "Use the same proxy for all protocol" unchecked as Sahi does not understand protocols other than HTTP
  • NOTE: "No Proxy for" should NOT have localhost in it.

    Internet Explorer:
  • Go to Tools > Internet Options > Connections > LAN Settings >
  • In "Proxy server" section, Check "Use a proxy server for your LAN"
  • Set "Address" to "localhost"
  • Set "Port" to "9999"
  • Leave "Bypass proxy server for local addresses" unchecked
  • OK > OK : )
While working with Sahi it may become annoying to have to switch between proxy and no proxy, or to another proxy.
There are a few plugins/freeware available on the net to ease this.
My personal favorite while working on Firefox is "Proxy Button". It helps in a single click toggling of proxy.
These tools can considerably enhance the experience of using Sahi.


Starting the bundled demo web server if needed, for learning and understanding Sahi APIs:
Windows:
- Go to <sahi_root>\bin and run web.bat
Linux
- Go to <sahi_root>/bin and run web.sh
Go to url http://localhost:10000/demo/index.htm and play around with the different pages.
It gives a fair idea of how elements are accessed through Sahi.

Note that by default Sahi uses port 9999 and the web server uses port 10000 (sahi's port + 1).
These can be modified through sahi.properties
(Top)

Recording through Sahi

  • Press ALT and double click on the window which you want to record.
  • On the popup that appears, give a name for the script you wish to generate, and click 'Record'
  • Most actions on the page will now get recorded.
  • Moving the mouse over any html element while pressing Ctrl key will show the javascript accessor info in the popup.
  • Clicking the "Add Assertions" button generates assertions for the element. These assertions can be added to the script by clicking "Add to Script"
The script being generated can be viewed by opening the <script_name>.sah file in the scripts directory.
The script can be edited even while recording, so that logical segregation into functions etc. can be done as recording happens.
  • Once done, click stop.
Note that custom code can be tested, by entering code in the "debug" textarea and clicking on "Test ->".
The command will be executed and the result will be displayed in the textbox near the "Test ->" button.
Once confirmed that the desired result has been achieved, that code snippet can be added to the recording by clicking "Append to Recording"

You could use the demo application bundled with Sahi to get your feet wet.
(Top)

Playing back

  • Open (alt-dblclick) the popup window.
  • Select script file from the dropdown.
  • Or go to the "[from url]" section and specify the full url of the script file. (eg. http://proxyhost:proxyport/_s_/scrcipts/scriptName.sah)
  • Click 'Set'.
  • Wait for the pages to reload.
  • Click 'Play'.
(Top)

Suites

Multiple tests can be run through ant or a batch file/shell script.
Read more here
(Top)

Logging

Logs are created in "logs/playback/" directory.
Log results can be accessed on the browser through http://localhost:9999/logs/
(Top)
Please send your feedback to V Narayan Raman.