You are on page 1of 9

Macquarie QA Engagement Proposal

Sahi – Web Automation and Test Tool

Author:
Divya Peddi & Nivetha Padmanaban

© 2008 ThoughtWorks Ltd.

Version: 1.0

© 2008 ThoughtWorks Ltd. Use of the document is subject to the following conditions: 1. The contents of this document shall not be revealed to any third party without ThoughtWorks’ prior written permission. Page 2 Version: 1.0 . ThoughtWorks reserves rights at any time to revise. 2. 4. amend or withdraw this document and for any of these purposes to call for the return of this document. No part of this document may be reproduced or transmitted without the express written permission of ThoughtWorks Ltd.SAHI – Web Automation and Test Tool This document and the information contained in it are the confidential property of ThoughtWorks Ltd.

more secure. the open source model often builds higher quality. Open source tools help to take advantage of automation with no cost. more easily integrated software.xml  Active community support © 2008 ThoughtWorks Ltd. It multiplies one company's development capacity many times over. No more monopolies. An important factor in automation is the choice of testing tool. Bugs are more quickly found and fixed. this tool uses simple JavaScript to execute events on the browser. Sahi then injects javascript so that it can access elements in the webpage. Developed in java and JavaScript. As a result. Sahi runs as a proxy server and the browser needs to use the sahi server as its proxy. And it does it at a vastly accelerated pace and often at a lower cost . they can choose another without overhauling their infrastructure. Some of the features that sets Sahi apart from other tools are  Ant support for playback of suites of tests  Suites can run in multiple threads thus reducing the test execution time  External Proxy. change it. OSS is not taboo anymore: OSS gives control to the customer. worldwide community. HTTP and HTTPS support  AJAX support  Good Database and file support.  Simple APIs  Easily editable scripts (text files) – version friendly artifacts  Logging/reports  Tests do not need the browser window to be in focus  Supports javascript. it becomes necessary to have an effective regression suite to evolve the application. This paper elaborates on an open source tool called „Sahi‟.0 .SAHI – Web Automation and Test Tool Introduction: As application and domain becomes more complex. A Test Manager may prefer to have the option of working with an open source tool in order to contain project cost. About Sahi: „Sahi‟ is an open source automation and testing tool for web applications. No more technology lock-in. And when customers don't like how one vendor is serving them. This makes the tool independent of the website/ web application. but among an Internet-connected.  Editor support – Jedit has supporting sahi. Page 3 Version: 1. Everyone collaborates. You can see the code. buying a commercial tool may not be affordable for all companies. It is very dangerous to skip automation in such cases. Not just within one company. learn from it. with the facility to record and playback scripts. Most of the time. the best software wins.

The responses coming from the webserver gets injected in the beginning and end with javascript code to help me work with the objects in the app. Create scripts – Scripts can be created either using the Recording facility of the controller or they can be directly written using any editor. The scheduler function gets added into the array and then executed with delay. Page 4 Version: 1. 3) Configure the browser to use the sahi proxy.SAHI – Web Automation and Test Tool Facts about Sahi: Number of downloads till Jul 16. Controller has very powerful features like:         Recorder and Playback window Show “accessor” of the element DOM path of the element Value of the element List possible assertions for the element One / more commands can be executed Shows the list of properties like scrollHeight.7% Role of Proxy in Sahi: Two things that happen in proxy---1.net Activity in sourceforge. Getting Started: Initial Setup 1) Download and Install sahi from sourceforge. Script here gets modified in the proxy.0 . 2007 is 19385 Ranked as 581 in sourceforge.net is 99. 2) Start the sahi proxy. Controller Screenshots – Controller can be launched by ctrl+alt+dblclick on the browser window. And all API's get changed to sahi_ 2. currentStyle etc for the selected element Can view the list of API‟s © 2008 ThoughtWorks Ltd.

All actions should be performed using them. _click. _rightClick Example of API usages – © 2008 ThoughtWorks Ltd.SAHI – Web Automation and Test Tool Fig .0 . Page 5 Version: 1. Ex – _button. Ex . _cell.Sahi Controller APIs: There are two kinds functions : a) Normal Functions – These are the functions which are primarily used to access the elements on the web page. _textbox Some other examples which are not for accessing elements on the web page – _getText . _getGlobal b) Scheduler Functions – These are the functions that schedule the action for later execution with a delay when its time comes._assertEqual.

jdbc. Execute API: Any DOS/Unix commands can be executed. "password") var $rs = db. For ex.This invokes the call and waits till mkdir is done."")).indexOf("---------. _assertEqual("Kamlesh". $rs[0]["AGE"]). sahi script automatically inherits the power of javascript.OracleDriver". var db = _getDB("oracle. $rs[0]["NAME"]). which returns the full file in single string and .split("\n").0 . } _assertTrue(getTextMessage(). $rs[0]["ID"]).replace(/\n/g.split function can be used to read line by line.Forwarded message ----------") != -1). . loops.select("select * from User"). _execute("mkdir abc".replace(/\r/g.SAHI – Web Automation and Test Tool _click(_image("Inbox")) _assertEqual(“text message”. _readFile("filePath"). Page 6 Version: 1. So. File Access: Files can be accessed through provided APIs.driver. true). _readFile("filePath").This invokes the call and returns immediately. © 2008 ThoughtWorks Ltd. function getTextMessage() { return (_byId(“mail_text”). "jdbc:oracle:thin:@dbserver:1521:sid". _execute("mkdir abc") . conditional statements etc.value. _getText(_byId(“mail_text”)) Sahi Scripting: Sahi script is based on javascript. Database support: Sahi supports database connectivity.""). like functions. For ex. variables. where split is an javascript function. where script can connect to database during runtime to execute any queries. "username". where $rs gets an 2 dimensional array of values and can be verified as _assertEqual("1". _assertEqual("28".

0 .xml file. Facilitates parallel execution of the tests .This spares the QA of the burden of having to explicitly run the tests.This opens multiple browser windows. and logs the results. Ant integration offers several advantages – 1. 2. By including a small snippet of code in build. Screenshot of Cruise Page – © 2008 ThoughtWorks Ltd.SAHI – Web Automation and Test Tool Ant Integration: Sahi has ant integration. it is possible to run a suite of sahi tests. The QA just needs to keep a tab on the build status and analyze the results in case of a failure. This considerably reduces the execution time of the suite and reduces the turnaround time of testing. Facilitates running of functional tests as part of cruise control . Page 7 Version: 1. executes sahi scripts.

where report just says the script name and its result.SAHI – Web Automation and Test Tool Reporting Two-level reports will be generated. © 2008 ThoughtWorks Ltd. Sahi follows the color code (green for pass and red for fail) for reporting which helps to locate the failed script easily. First level is consolidated report as shown in the below screenshot.0 . Page 8 Version: 1.

in/ http://sourceforge. References: http://sahi.net/forum/?group_id=151639 © 2008 ThoughtWorks Ltd. the most common scripting language. It is easy to adopt Sahi as it uses javascript.0 .net/projects/sahi/ http://sourceforge. sahi is stands out from other open source tools. Conclusion: Sahi is one of the open source testing tool for web applications available in the market and because of all above features.co.SAHI – Web Automation and Test Tool Second level of reporting is the detailed report. This report shows the each line of the script and follows color code for asserts as shown in the below snapshot. Page 9 Version: 1. which shows the detailed script. Sahi has very active community and discussion forum.