SAHI… Makes the Life of a Tester Easy!!
Posted by Basant on November 26, 2007
It was the other day when I was trying to automate a web 2.0 application with WATIR -an open source automation tool for web UI testing, that I was stuck in the landing page of the application trying to capture the sign up flow. It turned out that the sign up required an AJAX call used widely in every Web 2.0 app. Having forced to explore other alternatives for Web automation testing which would support AJAX calls, HTTP/HTTPS, I-Frames and Javascripts, I zeroed in on SAHI – a light weight web automation tool which I found supported all of these and offered more.
Thanks to a bangalorean named Narayan Raman from ThoughtWorks who developed this web automation tool in java and javascript, it made the life as a tester a lot more easier. This tool uses simple javascript to execute events on the browser. Like any other automation tool available in the market, it has the facility to record and playback scripts. Sahi runs as a proxy server and the browser needs to use the sahi server as its proxy. Sahi then injects javascript so that it can access elements in the webpage. This makes the tool independent of the website/ web application.

Sahi boasts of a heavy feature set including in-browser controls, intelligent recorder, text based scripts, ant support for playback of test suites, multi threaded playback, supports external proxy and HTTP/HTTPS, Dynamic applications and AJAX support, URL based script access, ANT support for running test suites, Script refactorable into functions and files and Accessor Viewer for identifying html elements for scripting. In addition to these data driven testing is possible by reading data from excel sheets and working with databases.
Running overnight batch runs are also possible using test suites integrated with 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 demo.suite.
The syntax of writing the suite file is:
eg.
test1.sah /startPageForTest1.jsp
test2.sah http://www.d2.com/startPageForTest2.htm
test3.sah abc/startPageForTest3.htm
Ant target for Internet Explorer:
< sahi suite="../scripts/demo/demo.suite"
browser="C:\\Program Files\\Internet Explorer\\iexplore.exe"
baseurl="http://serverName/path/"
sahihost="localhost"
sahiport="9999"
failureproperty="sahi.failed"
haltonfailure="false"
threads="3"
>
Ant target for firefox:
< sahi suite="../scripts/demo/demo.suite"
browser="C:\Program Files\Mozilla Firefox\firefox.exe"
baseurl="http://serverName/path/"
sahihost="localhost"
sahiport="9999"
failureproperty="sahi.failed"
haltonfailure="false"
browseroption="-profile ${basedir}/browser/ff/profiles/sahi$threadNo"
threads="3"
>
Sahi has a vast follower base appreciating its simplicity and easy to bend features with its JS engine. Sourceforgenet has hosted an online community to support the members/users spread across the globe under help and Open discussions.
Sahi is a free, open source software released under the Apache License Version 2.0 and
hence can be downloaded from sahi.co.in
