Blog

Latest Updates. News. Insights. Ideas.

June 2009 - Sahi Pro

Parsing XML in Sahi scripts

Posted by | features, Sahi, tutorials, XML | 2 Comments
Sahi uses Rhino as its javascript engine and Rhino has excellent support for handling XML.
Below is a script which reads and asserts XML nodes and attributes. The example has been picked from http://www.ibm.com/developerworks/webservices/library/ws-ajax1/ so that it is easy to experiment with the ibm examples in this script.


var xmlStr = '' +
'' +
' ' +
' Ant' +
' Shaggy' +
' Blue' +
' 176' +
'
' +
' ' +
' Paul' +
' Spiky' +
' Grey' +
' 178' +
'
' +
'
';

var $x = new XML(xmlStr);
_assertEqual("Ant", $x.person[0].name.toString());
_assertEqual("Grey", $x.person[1].eyes.toString());

for each (var $p in $x.person){
var $measure = $p.height.@measure.toString();
_assert($measure == "metric");
_assert($p.height > 170);
}
Two points to note:
1) All nodes that you access are of type xml. You will need to use toString() on them before you assert them.
2) Using @ from inside a Browser Action Function (like _click, _assert etc.) causes the script to fail because of a parsing error in Sahi’s code. So first assign it to a variable and then use it, like it has been used for $measure. This bug will be fixed in the coming release.
There is a lot more that can be done with the XML object. Have a look at these links:

Configuring Eclipse for Sahi

Posted by | eclipse, IDE, Sahi, tutorials | No Comments
Eclipse’s JSDT plugin provides syntax highlighting and verification for Javascript. It can be configured to work well with Sahi scripts too. This video goes through the different steps to configure Eclipse to work with Sahi scripts.

JSDT looks at all functions in the given source folder and can list them in content-assist. Taking advantage of this, we use a dummy definitions file called apis.sah which has all the Sahi APIs. This file, apis.sah, can be downloaded from here and needs to copied into the “scripts” folder.
JSDT is a part of the Web Platforms Toolkit.
It can be installed as a plugin or can be downloaded as a single bundle in the “Eclipse IDE for Java EE Developers (163 MB)” (For windows: eclipse-jee-ganymede-SR2-win32.zip). This is downloadable from http://www.eclipse.org/downloads/

Increasing interaction with Sahi users

Posted by | marketing, Sahi | 2 Comments

Sahi has been around for about 4 years now. It started in 2005 and was released before or just around the time Selenium RC’s first cut was released. But there has been a huge gap in the visibility of Sahi and Selenium. While Selenium seems to be everywhere, Sahi is hardly heard of. After a lot of conversations with different people, this is what we learnt.

1) Sahi is aimed at testers and not developers. Its focus on strong record and playback and on simple scripting, is primarily meant for testers in the Indian industry. These are people who are good at manual testing and automation with tools like QTP, but are not from a programming background. Selenium and Watir on the other hand are aimed at testers and developers who are fine with programming. Unfortunately for Sahi, testers in India who use Sahi, do not blog or voice their opinions on the internet, or contribute back in forums. (Most of those who do, are good technical testers.)  That meant that there was no viral aspect to the spread of Sahi.
2) Very little emphasis was made on Sahi’s website or in the program to collect user data. No testimonials, no newsletters, which meant that people were not informed of developments and good user stories to boost their confidence. While the program continued to evolve with releases every two months, few people really saw the progress. 
3) Being aimed at testers and using javascript for scripting, and because of our own lack of savvy in marketing to the internet, Sahi could never become sexy to the blogging bunch. Who would notice when there was Selenium and Ruby to talk about, which could get you more hits and popularity?
While the first and third problem cannot be solved easily, the second is quite addressable. A new section for testimonials and user stories has been added to Sahi Forums. This blog you are reading is being updated with new developments. Updates and news of Sahi can be followed via twitter at _sahi. Presentations on Sahi will be available here
If you are a Sahi user, tweet with #sahi so others may know. If you have a user story do post on the forums.

HTTPS Problem Resolution: Unable to tunnel through proxy

Posted by | technical, troubleshooting | One Comment
Sahi had been using its own custom implementation of proxy tunnelling till a few months back. Owing to a lot of demand for some features, we moved to Java’s httpsurlconnection which supported tunnelling through a corporate proxy with authentication. 
But unfortunately a bug in Java’s httpsurlconnection was tripping up a few users on some https sites. One case was the failure of websites using login via SiteMinder. 
The exception thrown was  
Unable to tunnel through proxy. Proxy returns “HTTP/1.1 400 Bad Request”
After some research we figured that it was due to this bug 6687282 
Switching to the latest java 1.6.0_14 fixed this issue for us.
Use fully-loaded Sahi Pro FREE for a month. Download Now Request a Demo