Sahi is an automation and testing tool for web applications. Different from many other commercial testing tools, Sahi is an open source tool. As an automation tool, Sahi provides the facility of recording and play backing of scripts. Sahi supports Java and JavaScript. Even though the Sahi script looks like JavaScript, it is not executed as the regular JavaScript on the browser.
The basic idea of how Sahi work is described below: Sahi's core parts include the Sahi proxy server and the JavaScript engine.

HTML responses which pass through the proxy are modified such that JavaScript is injected at the start and the end of the response. This will allow the browser to record and playback scripts and talk back to the proxy when needed. Apart from handling requests for pages that the browser requests, Sahi also handles custom commands related to recording, playback etc. which the browser sends.
Besides the normal features like supporting ant, Sahi has its own features, like good support of database files, supporting JavaScript, AJAX and also the simple APIs.
Compared to other web testing tools, Sahi controller (IDE) can be used in various browsers.
Sahi's APIs do not depend much on the HTML structure. Sahi does not use XPaths and has APIs like _near, _in etc. to help finding one element in relation to another. Even if the structure of the page changes, these work properly. Our client website is an ExtJS site; Sahi is helpful in dealing with the changing pages.
First of all, we can download the latest Sahi zip file from sourceforge. The prerequisite for Sahi is JRE 1.4 or above.
After finishing the setup, we can start creating scripts. The scripts can be written using any text editor with the facility of recording by controller. Press ALT and double click on the window, which you want to record.
The controller is as below

Note that custom code can be tested, by entering code in the "debug" text area 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".
Multiple tests can be run through ant. For each test in the suite, the ant target opens a browser, runs the test and closes the browser. The ant target specifies a suite file, say SuiteName.suite.
Sahi has some inbuilt features for data driven testing. Sahi can read and write to CSV (Comma Separated Value) files, databases and Excel sheets.
View Sahi in-detail with more examples in part 2 of this article.