Open Source Tools – Using Sahi for Automation
Abstract – Using Sahi for Automation
We engineers suffer from paranoia of fear of the unknown, so either try to start via some acclaimed test automation tool or want to build tool from a scratch trying to either save us from troubles and in the later case maybe marking our capacity or potential without actually realizing what would help the organization when it comes to web related test automation. I confess myself to be the first one on the list.
During one of the days, we were trying to do a yahoo messenger related test automation using QTP. So we had to actually burn nights to make it work because of the complexities of the tool. Once I did the entire stuff in perl and thought that the customer would be more than happy,. unfortunately it turned out to be the other way round. In Software engineering we often say, “Client is always right” alternatively in product companies, “Boss is always right”.
I was told to explore Sahi for our product test automation, where we have 100% Systems tests automated using one of the Mercury products. And its been a while since I had seen sahi, and was quite apprehensive about the tool. It turned out to be the other way round.
My sincere thanks to the open source community and all the others who have been directly or indirectly making a difference to the industry.
For Web related Test Automation, its worth exploring Sahi. That’s all I needed to say. Here is how: practically demonstrated.
- Just download from sourceforge and unzip the installer in C: or whatever drive you wish to.
- Go to the bin folder and double click demo.bat, in case you want to see a demonstration and play with it.
- Here is how it works: uses proxy server as a port to communicate 9999
- Based on rails concept of constant integration. Which means as you keep adding scripts, just need to put them in the scripts folder and it takes care of the rest. NO
compilations and installer builds and so on. It happens to be based on interpreter concept. Below is the directory structure for better visualization and understanding.
Note: There are lots of other dependencies that need to be taken care of before make it work in the first go. And you really do not get the bells and whistles of the other traditional
test automation tools. Mentioning here is going to be too much. Please refer to the flash tutorial available on the sourceforge download site of sahi
Lets Hit Implementation:
Using Sahi for Performing Search and displaying the test results.
Pre-conditions to run the test:
Sahi installed in the directory and the machine has jre installed (run-time environment) to use sahi and the port settings configured to use proxy server with port 9999
- Invoke the browser.The browsers hould get invoked.
- Navigate to sahi\binfolderanddoubleclicksahi.bat
- The following screen is displayed.
- Notice the screen contents, mostly self explanatory.
- As displayed in the screen, pressing the control key, double click the browser.
- It will invoke the Controller Window (The recording brain of Sahi). Please refer to the illustration
- Move the controller window on the browser, pressing the control key move the mouse over various fields/controls in the site. As you keep scrolling, you will notice that the accessor (identification names also keep changing to the ……
- Go to google.com
- Click Record
- Search for a string
- Hit Return
Click the Stop button.
Now comes the Verification part:
- Go to the playback and invoke the controller window
- Specify the url (web url which you need to navigate to) google.com in our case.
4. Record/Notice the test result
Trust me, it will be a breeze and a flawless run.
The results captured (as default sahi settings are) displayed in the Test Results Window above.