Blog

Latest Updates. News. Insights. Ideas.

Sahi Archives - Sahi Pro

Common mistakes while using Sahi Excel Framework – Data Driven Testing

Posted by | Sahi, troubleshooting, tutorials, Uncategorized | No Comments

Sahi Excel Framework is a powerful feature which bridges the gap between domain experts and automation engineers. We had highlighted Sahi Excel Framework in our Five Questions Series here: http://sahipro.com/five-questions-series-sahi-excel-framework/

In this post, we intend to highlight the common mistakes people make while using Sahi for Data Driven Testing

Syntax and Data File Errors:

  • Missing = after the variable name.
    Some testers seem to read the external file and store the data (array) in a variable. They miss out the = after the variable name.
    Incorrect Usage:
    variableName _readCSVFile(“fileName”)

    Expected Usage:
    variableName= _readCSVFile(“fileName”)Error

  • A common mistake observed was the usage of _readCSV, _readExcel instead of _readCSVFile and _readExcelFile.
  • Using the incorrect API to read the external files
    There are three APIs you need to be aware of: _readCSVFile, _readExcelFile and _getDB. You need to use these APIs based on where you are saving your test data which could be CSV, Excel or a database.
  • First column is not empty. There should not be any data under the first column header.
    Expected: BlankColumn
  • Mismatch in the header names. The data from the column will not be considered if the header name doesn’t match in the scenario file and data file.
    Headers
  • Keyword and Data are not enclosed in square brackets
    [Keyword][Data]
  • Instead of [variable:header:columnName], many testers have used [variable:header.columnName] They have used . instead of : and you would notice that the values would not be picked up for the fields.
    DataNotPickedUp

Which other issues have you encountered while using Sahi Excel Framework for Data Driven Testing? Do let us know through your comments.

Five Questions Series: Sahi Controller

Posted by | features, Sahi, tutorials | No Comments

Each week, we will pick a feature of Sahi Pro and hope to highlight its capabilities, benefits and tips on how to use it effectively by asking not more than five questions. We begin our Five Questions Series on Sahi Pro by focusing on Controller.

What is Sahi Controller?
Sahi Controller allows you to interact with Sahi and easily experiment and debug on the browser. Using Sahi Controller, one can easily identify elements, record and playback the scripts. One can launch Controller by pressing ALT and double clicking anywhere on the browser. Kick-start your web automation by recording using Sahi Controller and using the scripts as it is or creating functions out of the recorded snippets of code.

What are the capabilities of Sahi Controller?
Sahi Controller has many powerful capabilities spread across four tabs?—?Record, Playback, Clipboard and Info.

Sahi Controller

Sahi Controller

Record: This tab has controls to record a script. Recording is as easy as entering a name for the script and clicking on Record button. All the actions performed on the browser will be recorded and displayed in ‘Recorded steps’ tab.

One can identify elements using CTRL + mouseover and the Sahi Accessor for the element is displayed. Other actions like Click, Highlight, Set, Hover can also be performed on this element.

Action Buttons

Action Buttons

As seen in the image, each button invokes a        specific API.
  Click: _click API
  Hilight: _highlight API
  Set: _setValue API
  Hover: _mouseOver API

 

 

Assert: One can add assertions to verify if the end result is as expected. To add assertions, CTRL+mouseover an element. Click on ‘Assert’ button to view the possible assertions. It will be displayed in the ‘Evaluate Expression’ tab. Once tested, the assert statements can be appended to the main script.

Evaluate Expression: This can be used to evaluate snippets of Sahi code. Clicking on Test will evaluate the content and display the result (true/false/undefined) in the box below.

Smart dropdown for Evaluate Expression: If one wants to use Sahi API on only a part of the expression in the Evaluate Expression box, select the text and choose an action from the dropdown. This would in turn trigger an API and the results will be displayed in the box below. In this case, the ‘Is Visible’ option to trigger the API ‘_isVisible’ on the element ‘_textbox(“total”)’ is highlighted.

API on an element

API on an element

Playback: Using this tab, one can playback the scripts which are already recorded. Providing a Start URL and checking the checkbox will ensure that the script runs by first navigating to the URL mentioned. If the checkbox is not checked, the script will be executed on the current page without refreshing it.

Sahi Record Tab

Sahi Record Tab

Clicking on each of the links will open the respective window. For ex: Clicking on Logs will display the logs for all the scripts run so far. Clicking on a specific script on that page would display the specific logs.

Clipboard: This tab can be used to store small pieces of information.

Info: This tab shows the basic information of Sahi Controller, mode, browser, operating system and Java.

How are the elements on a web page identified?
Any element on the webpage can be identified by pressing CTRL and mouseover the element. The best Sahi accessor for the element is displayed by default in the Accessor field. One has the option to choose an alternative from the ‘Alternatives’ dropdown. Value shows the value of the current element. Prefix populates the prefix as needed when working with popup windows and multiple domains.

Element Identification

Element Identification

Tell us more about the Relational API and anchoring an element.
Sometimes, an element changes its position/name due to code changes and the whole script fails as the tool is not able to identify the element. To get rid of this issue, a very powerful option is Relational API and anchoring an element.

Let us take the following example where we have to identify the quantity field against “Ruby for Rails”.

Relational API

Relational API

If we identify the field in isolation, the Sahi Accessor reads:
_textbox(“q[1]”).
What if three more book titles are added before Ruby for Rails. The Accessor for the field against Ruby for Rails also changes. To avoid this situation, let us anchor the label ‘Ruby for Rails’ first and then identify the field against it.

Identify Ruby for Rails field

Identify Ruby for Rails field

Anchor the field

Anchor the field

Identify the quantity field

Identify the quantity field

How does recording with ‘Enable Accessor Repository’ on help?
If ‘Enable Accessor Repository’ checkbox is checked, Accessor Repository file text field appears. Once the user clicks on ‘Record’ button, Sahi will record using Accessor Repository. In the ‘Accessor Repository File’ text field, we mention the relative or absolute path to the Accessor Repository file.

Accessor Repository

Accessor Repository

Once a Accessor Repository file is chosen, an element will always be identified first by its AR entry, even when not in recording mode. This prevents the same element from being identified in multiple ways in different scripts.

When elements have been smartly identified using Relational APIs like _near or _under once, newer recordings on those pages will simply use the AR entry, so other users do not need to worry about doing it again or wrongfully using a different identification mechanism.

One important thing to note with Accessor Repository keys is that they must always be in the format $_ALL_IN_CAPS. If this is not followed, the scripts will still work fine, but the values will not come up properly in Script Editor’s context panel.

Any other questions in your mind?

Feel free to comment or ask your question(s) and we will get back to you.

Sahi Pro – Cheat Sheet for Download

Posted by | Sahi, tutorials | No Comments

When we start using powerful products like Sahi Pro, we look forward to using it to the fullest. Sahi Pro has many APIs that can help us with our testing. Some of the categories of APIs include
– File APIs
– Action APIs
– Fetch APIs
– Script Execution Control APIs
– Masking APIs

We have come up with a cheat sheet to help you refer to the different APIs at a glance. Download the cheat sheet from the below links:

cheat_sheet
PNG
PDF

Let us know what you think about the cheat sheet. Is it useful? Have we missed anything? Feel free to talk to us at support[at]sahipro[dot]com

Interview with Sahi Pro – The Tester’s Web Automation Tool

Posted by | Sahi, web automation | No Comments

I am Ajay Balamurugadas and I welcome you to our weekly show where we interview one of the promising leaders of the industry. It gives me immense pleasure to introduce today’s guest. He has been a consistent performer in web automation and built a strong hold in a very competitive market. When everyone built the automation frameworks, he focused on what is important – automating the checks. His unique philosophy of helping the tester makes his tagline – “The Tester’s Web Automation Tool” the Sahi (correct) tagline for him.

Without further ado, let us welcome –
Sahi Pro: The Tester’s Web Automation Tool

Ajay(A): Hello, Sahi Pro. Welcome to the show. We are very excited that you are here today to interact with us and share your expertise. You are one of the few automation tools who is tester-friendly and gets the job done in a simple manner. Tell us about yourself and your journey.
Sahi Pro(SP): Thank you, Ajay. It is my pleasure. I started as an open source product and then due to customer commitments, I started to focus on my Pro version and fulfill customer expectations. I noticed excellent testers struggling to automate due to complex automation tools. So, I evolved to enable subject matter experts and testers to get into automation easily.

A: Yes, that is indeed strange. When everyone around you focuses on building a robust framework and turning testers to coders, you have taken a different route altogether…
S: I will not say that we have a taken a different route for the sake of being different. My thought process is continuously evolving based on the testing industry and trends. I quickly realized that most of the end users were expected to be technical programmers or automation engineers. They were expected to build a framework from scratch, get the developers write code to align with the element identification mechanism and after all this, focus on automating the checks.

I found it quite disturbing. The purpose of web automation is to automate the checks, give the testing team the confidence that the regression bugs they expected to find are not present. The tool should free up the tester’s time. Testers should explore the application and find more critical bugs. I don’t expect my users to be technically super-strong. I take care of everything to help the tester, right from identifying the elements, suggesting accessor alternatives, providing relational APIs, excellent logging and reporting, calling Java functions and libraries from my script, automatic screenshots on failure and believe it or not, I automatically wait for page loads and AJAX activities to end!!!

A: Whoa! That’s quite a big list of key differentiators! Tell us about your element identification mechanism.
S: I use my own wrappers around the Javascript DOM to identify elements. My APIs use various DOM attributes of an element to identify them. Instead of relying on a single attribute, I look for the element’s value, name, id, css class or index etc. So, I work well even if multiple elements have the same attribute value. If I am unsure about a particular element’s identification, I rely on my trusted advisor – the Relational APIs to identify one element with respect to another.

A: Many testers want to learn automation and give up as soon as they face problems in learning a particular language. What is you suggestion to them?
S: Yes, that is a common story. People are spending time learning the language more than automating the tests. I am not against anyone learning a language but let us remember why we started this discussion. A tool should enable people to automate and not set restrictions on the way. I am an extension of JavaScript and have a pretty good recorder which can create scripts for further usage. If you have never used any tool for automation, try me!!! If you already burnt your hands spending a lot of time learning a language with little success, let us pair together and see if I can help achieve your goals.

A: Are you only for newbies or can experienced folks take advantage of your prowess?
S: As I have already highlighted, my recorded scripts can be used as a good starting point for further scripting. My JavaScript is executed in a Rhino JavaScript Interpreter, running inside my proxy. As Rhino is a JavaScript runtime running inside a Java Virtual Machine (JVM), this adds a lot of power to my scripts. My scripts can directly call Java code in scripts.

A: I am sure, our readers are excited to try you and your APIs. Does anyone provide training or demo about you?
S: The folks at Tyto Software Pvt. Ltd seem to be quite helpful in this regard. Shoot an email to info[at]sahipro[dot]com or check out the documentation about me at http://sahipro.com/docs/introduction/index.html
I also meet my friends every Thursday in a webinar at www.sahipro.com/webinar

A: Thank you for your time, Sahi Pro. We wish you all the best for your future releases and features.
S: My pleasure. All the best for your series too.

Feel free to add your questions as comments and we will get Sahi Pro to answer for you.

Five salient features of Sahi Pro that may surprise you!!!

Posted by | features, Sahi, web automation | No Comments

I have been using Sahi Pro for some time and each time I face an issue, the Sahi Documentation has been of great help to me. Apart from the documentation, one would also appreciate the number of example scripts bundled with the product. After testing Sahi Pro on a variety of applications, I could not hold myself from highlighting  few salient features of Sahi Pro that may surprise you.

Automatically waits for AJAX and page loads

The first tool I used to automate my tasks was AutoIt and I had to add lots of Sleep(5000) or WinWaitActive ( “Create a New Post”, “” , 10 ). A quarter of my code had these Sleep commands. I had realized that these commands were very powerful essential to ensure that my scripts did not fail during the demo. Then I shifted to Selenium and things were no different. My friends who used Selenium in their day to day work had explicit code for wait.

And when I started using Sahi Pro, I was surprised at how Sahi Pro automatically waits for all the AJAX activities to finish and waits till the page loads completely. I did not have to add even a single line for wait. Isn’t it surprising? What surprised me more was that it was NOT necessary to have the browser in focus.

Record in one language and playback in another language

Do you know the average number of languages the top 25 websites support? As per the Web Globalization Report Card 2015, the number is 45. Very soon, you will have your web application support multiple languages. It is quite easy to automate for English language but your customers are from different countries and use other languages.
What would be the cost of automating across languages? Think in terms of the language experts, the automation engineer effort and the confidence you get with such an exercise. Just when we thought that it would be a costly exercise, Sahi Pro comes to the rescue with the API named _setLanguage
More details about the API here.

In-built reporting system and automatic screenshots on failures/errors

It is no wonder that people love reports. Even if someone is not willing to get technical about what’s happening in the code, they want the high level reports. How the product is performing over a period of time? How are we on the automation front? When was the last time the automation suite passed without any failures?
Creating an automation suite is itself a challenging task and to build a custom reporting module is no mean feat. Sahi Pro’s reporting module is amazing and will surprise you with the clarity of reports.And every time the script fails, Sahi Pro will automatically capture a screenshot. One need not add explicit code to take screenshots.

Excel framework – Faster collaboration between domain experts and automation engineers

Sometimes, it is easier to automate scenarios than to convince people of the value of automation, done right. People resist change and fear if their jobs will be replaced by automation. Domain experts are not willing to accept that they are not strong in programming skills and automation engineers are not sure if they are automating the right stuff.

Imagine a platform for the domain expert to provide their views and the automation engineers use the input to translate it to code. Sahi Pro’s Excel Framework aims to be the platform. The domain experts need not know how the code is implemented. The intent and the implementation is clearly separated in the framework.

Call Java libraries and APIs from Sahi Script

Sahi’s Javascript is executed in a Rhino Javascript Interpreter, running inside Sahi’s proxy. Only relevant individual statements are sent to the browser for execution. The rest of the runtime happens in Rhino inside Sahi’s proxy.
Rhino is a Javascript runtime running inside a Java Virtual Machine (JVM). This adds a lot of power to Sahi scripts. Sahi scripts can directly call Java code in scripts.

Isn’t it wonderful that you can leverage the power of Java libraries and APIs directly from your Sahi Script? Add to it, the power of Relational APIs like _near, _rightOf, _under and you will be surprised at how easy it is to use Sahi.

Have you used Sahi Pro? Which features are your favorite? I have listed my favorite five. Let me know your favorite ones in the comments.

If you are new to Sahi Pro, check out the weekly webinar at www.sahipro.com/webinar

Five reasons why Sahi Pro is not for you

Posted by | Sahi | No Comments

Sahi Pro is NOT the Sahi Choice, Baby !!!

Everywhere you see, people sell you something or the other. Someone asks you to buy food from their app, someone asks you to book flight tickets while someone else is ready to help you find the right job for you. We are surrounded by products and services. Consider the field of web automation and there are at least ten products you can name right now. Are they worth the hype? That’s a different story for another day. Today, I want to highlight why Sahi Pro is not the right choice for you.  Yes, you read it right! Why Sahi Pro is not the right choice for you!!! I will give you five reasons and you can let me know which one is true in your case.

Reason 1: Already Budgeted and Approved.

You planned for the automation in your testing strategy. You finally got the plan approved by your manager. The budget for the automation team was approved. Your whole plan is ready and you love playing with XPaths.  After so many days, if you go for Sahi Pro now, all your plans will go haywire. You don’t want to risk that danger. You don’t have the courage to accept the change in plan to your manager. If this is the case, I promise you Sahi Pro is not the right choice for you. As Sahi Pro doesn’t rely on XPaths, it will expose your poor planning. So, don’t go with Sahi Pro and continue playing with XPaths and the game of thrones identifying elements.

Reason 2: Automation Engineers will lose their jobs.

You are proud of your strong team of automation engineers. You did not make the mistake of hiring a tester and turning them into bad programmers. You hired quality automation engineers and that masterstroke is still praised by many. Any requirement for automation and your engineers love it. They jump on it and finish it to everyone’s satisfaction. Everyone knows that you don’t really need specific automation experience to get started with Sahi Pro. The moment you get your hands on Sahi Pro, you will have to bid goodbye to your team members. You will be asked questions like “Why did we not use Sahi Pro till now?”, “If we don’t need automation engineers from today, why did we have them till yesterday”. Many more such tough questions would be fired to you and you will have to deal with them. The easiest way to avoid such questions is to continue the existing plan, team and forget about Sahi Pro.

Reason 3: Testers favorite and no more regression testing.

Many test leads are afraid of regression bugs (bugs found during regression testing). They delay the new feature development and focus on regression testing for many days/weeks to avoid such bugs. As of today, you ask your testers to focus on ensuring that nothing breaks due to new code/fixes. The day you get Sahi Pro, testers will love it and focus on Sahi Pro to automate the regression scenarios. Their focus will now shift to finding new bugs and take up the investigative role rather than confirming that old things continue to work.

Isn’t that a big risk you will take? More bugs would mean delayed releases and what will happen to your reputation then? Who will protect it? Better ignore Sahi Pro and let the new bugs lay hidden in the code.

Reason 4: You are too organised to like Sahi Pro.

Like every other company, you proudly advertise that your product works on almost any web browser. As you are too organised in your professional life, you love to maintain scripts for each browser separately in a separate folder. You don’t believe in the concept of one script that runs on multiple browsers. It looks like a big joke to you. Alas, Sahi Pro has the feature of One Script – Run on Multiple Browsers and hence, it fails to impress you.

Accept our sincere apologies and continue to write individual scripts to suit each browser. The last time we contacted Sahi Pro, they were not ready to remove that feature.

Reason 5: You refuse to acknowledge ‘Sunk Cost Fallacy’.

You spent money hiring a team, building an automation framework, buying an expensive tool and trying to change everything under your control to make the automation a huge success. A small change in the application is making your team put in extra hours. Everyone is able to see that it is more costly to maintain the automation scripts compared to the value by running them. Yet, you have taken it to your heart and refuse to acknowledge the ‘Sunk Cost Fallacy’.

Like many of us, you repeat this to yourself multiple times:
“We have invested so much money in it. If we stop now it will all have been for nothing.”
You are right. There is nothing called Sunk Cost. You carry on with the existing tool till you leave the job. Sahi Pro will ensure that you get out of the fallacy, which is dangerous.

Many folks have one or the other reasons not to use Sahi Pro. What about you? 

Sahi Pro helps

  • identify elements easily
  • by making life of automation engineers and testers better
  • testers to find new bugs
  • by making a single script run on multiple browsers
  • you get out of the trap and actually save money and time.

    We are just an email away: info[at]sahipro.com

Feel free to approach us. We love solving authentic problems. There is a weekly webinar that talks about Sahi Pro every Thursday 8.30pm to 9.30pm IST. Do attend and pass this information to anyone who would be interested.

Sahi_Webinar

Is This Your Automation Story? – From the “NEED” to “SUCCESS”

Posted by | Sahi | No Comments

Your product simplifies business critical workflows for banking organizations. Your product has complicated workflows which are accomplished by navigating through various forms and screens of your web application. Currently you are doing a lot of manual testing. You have testers who understand your domain well and are good at identifying problem areas. These testers are not programmers, but use computers to get their job done.

Sometime back you moved to faster releases. The development could cope with it (or so they believed and claimed). But testing started lagging behind. You realize that a lot of time is spent verifying older functionality. So you start skipping some parts of it. One day your friendly customer calls and says, hey, I am no longer able to edit loans as a manager. A CRITICAL BUG! Your mature, smart testing manager resists the temptation to shift blame (thank god for that!). You discuss with her and realize the manual testers are overwhelmed by the speed of releases. Bugs are slipping through and they are frustrated.

The NEED:

You realize YOU NEED AUTOMATION. And that you have no clue how to go about it.

So you ask your testing head. She says she knows this tool which she has seen used in an earlier organization. You look at the cost and blanch. You still go ahead and evaluate it. You think you will just have one tester on automation then. The testers are able to understand the tool and work with it. Unfortunately it does not support some components on your web application. You are silently relieved that you did not have to justify such a cost and make the compromise of using just one automation tester!

The EXPERIMENTING:

Next you ask one of your developers. He has heard a few things and suggests that you go with product B. You ask him if he has used it. He says, he has not, but EVERYONE seems to be using it. Many of the bigwigs are using it too. It is open source and free too! Wow! – you say. Let’s try it. The testing head is a little cautious. You are mildly irritated with her and assign the developer to do a Proof of Concept. The first trivial demo goes through. The enthusiastic developer blogs about it. He then goes on to do the POC. He needs to demo it in 2 weeks.

Demo day. You see your application run automatically through a flow on Firefox. You are impressed and happy. Now your developer takes you through the code behind it. You see code. Lots of it. In Java. And cryptic long strings as identifiers. Lots of code with JavaScript expressions as strings. This seems complicated. You worry now. Can your testers do this? You ask if it runs on Internet Explorer 9 where your customers are. The developer says the tests seem to freeze up and crash and he suspects some bug in his code which he will fix. The testers want to try their hand. Install Eclipse he says. They have never used an IDE. They are excited with the new toys. The developer is surprised they don’t know Java and are staring at him blankly when he asks them to write a TestNG test. He explains and a few testers nod. He goes on to identify elements using the developer toolbar and does some copy pasting of xpaths etc. XPath? What is that asks the tester. He explains, but is starting to get frustrated. They seem to know nothing he thinks. “Can’t we use a recorder to build our tests?” asks a tester. Since the product does not have a recorder, the developer goes on to justify it that recorders are bad and you should always code. You sense that it is a cover up for a deficiency, but wait to watch how this plays out. Especially since you like the developer and don’t want to bruise his ego (little sensing how much you will regret this later). You allow the game to be played for a couple of more weeks. You think this may help the testers also scale up some skills.

A couple of weeks later, you talk to the team. The testers say they have not been able to automate much. The developer says they do not have the skillsets. You should hire automation engineers. You try out with two automation engineers. They don’t come cheap. They seem to love XPaths and adding waits and digging deep into browser developer tools. But one of them seems to not understand the business functionality. He even has a holier than thou attitude, as if testers who understand business, but cannot automate like him, are beneath him. The other one thankfully is saner. Both diligently dive in to create a “framework”. Your existing testers are getting demotivated. They fear they may be fired. You are getting frustrated too. You think maybe you should outsource this. You talk to a few vendors. They say they know the tool but you will need a framework. The framework will cost you thousands of dollars and a few months of effort. Automation can only start after that. You start budgeting for it. But you are worried. What will I do with my current testers? This all seems unnecessarily complicated. You sense that YOU ARE SOLVING TECHNICAL AND PEOPLE PROBLEMS INTRODUCED BY A TOOL RATHER THAN YOUR OWN BUSINESS PROBLEMS.

Thankfully, you talk to your friend who heads engineering in that clinical research company in the US. He tells you about another tool. A tool which has enabled his existing testers to automate. A tool which does not need XPaths or waits. A tool which has a good recorder. A tool which has inbuilt technology to ease every bottleneck you yourself have encountered so far. And a tool which works reliably across browsers. Fast. Even on Internet Explorer, which you have not been able to reliably run on yet with tool B. (Tool B’s fan boys kept blaming that IE is cr*p and is slow). And he raves about the support team which has bailed him out every time. They even shipped an entire new build in 3 days for one of his issues.

The SOLUTION:

So you change track. You ask your tester to evaluate this tool. It is called Sahi Pro. She schedules a demo from the Sahi team. She asks lots of questions. She does a screen sharing of her application and the Sahi team demonstrates how to automate it. She finds it easy. She does not know yet about running it in suites, distributing it across machines, taking screenshots, integrating with Continuous Integration systems etc. But she need not worry. Everything is inbuilt into Sahi Pro. The developer went through Sahi Pro’s documentation and found that it covers all of this. And your friend said it works too.

SahiPro-test-automation

The SUCCESS:

You are happy. You are happier to know its cost. And the fact that it allows flexible licensing. It all makes perfect business sense. Your developer who was handling automation is back to development. He was frustrated with the brittleness of the tests and having to interact with non-programmers. He is happy to go back to doing fun creative coding. His first love. The testers have automated a lot of scenarios now, especially with Sahi Pro’s inbuilt framework. One of the automation engineers who was hired is a little disappointed that he did not get to develop his own framework. He has applied for developer jobs elsewhere. The other automation tester has gone back to do what he loves – exploratory testing of complex business scenarios, while his automated tests verify known paths and regression scenarios reliably…

OpenSSL and Heartbleed clarification in Sahi Pro

Posted by | Sahi, technical | No Comments

One of our support requests asked about the version of openssl used in Sahi Pro. Since it may be of concern to others, here is some more information related to use of openssl in Sahi Pro.

The version of openssl is :
OpenSSL 0.9.8h 28 May 2008

OpenSSL 0.9.8h did not have the heartbleed bug. (“OpenSSL 0.9.8 branch is NOT vulnerable” from http://heartbleed.com/)
In Sahi, Openssl is only used to generate a signed certificate with Sahi’s CA certificate (also created via openssl).
All other HTTPS communication between browser proxy and server are done via Java’s built-in SSL implementation.
Sahi does not add its version of openssl into the system path, so it should not affect the rest of your system/application.

Sahi Pro v5.1.1 fast execution without waits on Chrome 34

Posted by | Sahi, technical | No Comments

Some of you may have noticed that Sahi Pro does not wait correctly for page loads since Chrome 34. This happens because of a change in window.document.readyState behaviour in (since?) Chrome 34.

To fix it, do the following:

Open sahi/userdata/config/user_extensions.js and add

// Chrome 33 fix start
Sahi.prototype.replace33 = function(fn) {return "("+(""+fn).replace("_isChrome", "isChrome33Minus")+")";}
Sahi.prototype.areWindowsLoaded = eval(_sahi.replace33(Sahi.prototype.areWindowsLoaded));
Sahi.prototype.ping = eval(_sahi.replace33(Sahi.prototype.ping));
Sahi.prototype.getChromeVersion = function() {
var m = window.navigator.appVersion.match(/Chrome\/(\d+)\./);
return m ? parseInt(m[1], 10) : 0;
}
Sahi.prototype.isChrome33 = function() {return this._isChrome() && this.getChromeVersion() == 33;}
Sahi.prototype.isChrome33Minus = function() {return this._isChrome() && this.getChromeVersion() <= 33;}
//Chrome 33 fix end

before the line:
__sahiDebug__("user_ext.js: end");

Restart Sahi, clear browser cache and check if it works. If you have trouble, please email support.

Sahi Pro V5.0 – What’s New?

Posted by | releases, Sahi, Uncategorized | No Comments

Download Sahi Pro V5.0

Major Changes:

Detached Sahi Controller
The Sahi Controller is no longer tied to the same domain of the webpage that is being automated. This fixes two problems: 1) multiple controllers opening up when navigating between domains/popup windows and 2) Controller not responding to some parts of the web page

External Proxy Configuration using proxy.pac file
Many organizations use a separate proxy.pac file to configure their complex proxy rules. Sahi now can be configured to use a proxy.pac file instead of a hardcoded external proxy.

Added support to specify suites inside a suite
Suites can now be included inside other suites, allowing easier management of suites.

Script parsing done via Rhino AST parser
Sahi has moved from its previous string based parsing to Rhino’s AST parser. This allows formatting Sahi scripts in similar ways as normal Javascript files. For example, multiple actions can now be written on a single line.

Parallel browser launching enabled from java driver
Multiple browser instances can now be launched using new Browser() instances. Previously this would cause clashes in browser profiles, which has now been fixed.

_setValue bug fixed for firefox 20+
We feel stupid, but the problem was that Firefox 20 was being identified as Firefox 2 by Sahi, and hence falling back to Firefox 2’s event simulation mechanism. (Who anticipated Firefox 20 within 2 years?!) This has now been fixed.

Java 1.7 – Browser opening bug fixed
Browser launching was broken for people who moved to Java 1.7. We have fixed this now.

Proxy Configuration bug in IE10 x86 version Fixed
The proxy would be set and unset immediately on IE10 x86 version. This has now been fixed. Similar issue with Safari on Mac also is fixed.

Reporting Mechanism Optimized
The previous implementation stored execution steps in memory till the end of a script and then wrote to the database. In case of long running scripts, the memory requirements became large and if there were any OutOfMemoryErrors, the script would terminate without any logs, causing frustration and wastage. From this release, the logging is done directly to the database at each step itself, so there is no memory accumulation. Even if scripts abort in between, the logs are available till the last executed step.

Minor Changes:

Allow playback of scripts without refreshing page (“Use Start URL” checkbox added)
It has been a long time complaint from our users that Sahi refreshes the page before executing a script. We have now made this optional via a checkbox. If unchecked, the script can be set and played back without reloading the page.

Make Streaming configurable
To accommodate technologies like Comet and Server Push, we have added streaming_contenttypes.txt and streaming_urls.txt which specifically tell Sahi to stream the content without buffering.

Added Diagnose link to Dashboard
If a Sahi script waits for a long time without executing the next step, one can click on the Diagnose link on the Controller to dump the state of playback. It helps diagnose problems with Sahi indefinitely waiting for AJAX activity to subside.

Added Sahi version to Dashboard

Added feature to set java path automatically during installation of Sahi

Added setFile2 API to Sahi Java

Added Start URL in reports

New APIs added:

  • _verifyLayout: Allows verification of Page layout
  • _readLayout: Reads a simple csv like file of Sahi Elements and converts it into 2D array to be consumed by _verifyLayout
  • _includeOnce: For complex nested scripts, allows including library files only once.
  • _openWindow: Opens a new window at given resolution. Helps testing responsive layouts along with _verifyLayout
  • _windowAction: Used to perform maximize, minimize, focus, refresh, restore and close window on Windows

Download Sahi Pro V5.0

Complete Changelog


07 May 2013
----------------
Sahi Pro V5.0 released.

* Features
Parallel browser launching enabled from java driver.
Added Start URL in reports
Updated the API list for Notepad ++ plug-in.
scrollOffsets added to mouse events
Added setFile2 API to Sahi Java
Added diagnose link to Dashboard
Added Sahi version to Dashboard
Script parsing done via AST parser.
Added _windowAction API which can be used to perform maximize, minimize, focus, refresh, restore and close window
Added feature to set java path automatically during installation of Sahi.
User Agent added to initialized.htm
Added support to specify suites inside a suite.
Support provided for Microsoft SQL database.
_verifyLayout and _readLayout API created
Make Streaming configurable; added streaming_contenttypes.txt and streaming_urls.txt
_includeOnce API added
_openWindow API added
proxy selector with pac file
Allow playback of scripts without refreshing page ("Use Start URL" checkbox added)
Detached Controller implemented to allow easy recording via multiple domains/windows without opening multiple Controller windows
New playback mechanism using ping

* Bug fixes
Fixed identification of divs where each text is encapsulated by 2 divs
Fix for very slow performance of removeComments. Fixes slow loading.
Log Exception takes to the correct line number in script.
Script parsing error reporting fixed.
Fix _under in IE.
_under and _above fixed to take offsets on both sides
Mysql logging fixed
.js files fixed to be treated as single .sah file instead of .suite
HAR logging fixed
changes to terminate a load test, if the capacity is exhausted on all nodes
Fixed "Test->" assert of multiple lines from controller
Dsync fixed to copy scripts to nodes from master if master is not in list
Update of suite reports result in dload fixed
_setValue bug fixed for firefox 20
Suite report time taken format changed
fixed: reports dumped to FS
database table creation fixed
load runner fixed
Status and graph for drun fixed
drun logs for suites fixed
leftOf, RightOf fixed
domanifix with 2 parameters fixed
Fixed reports for csv based suites
test case reporting fixed
_takeScreenShot fixed
Linux certgen problem fixed

Download Sahi Pro V5.0

Been a long year!

Posted by | Sahi, tyto | 2 Comments

2011 has been awesome for us. Tyto Software has grown and become a self sustaining unit with a team that has really come together. Sahi Pro is well received and we released V4.0 recently. We also added a lot of new customers; customers, who have expressed happiness at how our product works and how we support them. We added Flex capability, load testing, better reporting etc. to Sahi Pro, and the results have been very positive. A surprising hit feature was our Excel Framework, which saves a lot of time for users not very comfortable with programming.

While our support is generally well appreciated, we have been trying our best to keep improving on it. One sore point has been our lack of online payment processing methods, which we are trying to alleviate in January 2012.

Over all, we are geared well for 2012, having brought on a couple more to the team and put in processes which make the end user benefit a lot from using our product.

So where is Sahi Open Source? We have been very busy with the Pro version and we should be able to get a breather in January to port back fixes into Sahi OS.

Thank you all for your patronage, and wish you a very happy and prosperous New Year!

Sahi V3.5 2011-03-14 released

Posted by | releases, Sahi | No Comments

Sahi V3.5 2011-03-14 is now available on SourceForge.

  1. We have added support for HTML5 elements, so, for example,

    is identified by Sahi as:
    _numberbox("myId")

  2. Proxy switching on IE has become a little better
  3. _collect and _count have been added.

    Eg.

    [code]_assertEqual(5, _count(“_link”, “View Details”));[/code]

    and

    [code]var $els = _collect(“_link”, “/View/”);
    var $len = $els.length;
    _assertEqual(5, $len);
    _assertEqual(“View Details”, _getText($els[0]));
    [/code]
  4. Ignorable ids made a user modifiable property in sahi.properties/userdata.properties. So if you have a new framework which generates ids in a definite pattern, you can ask Sahi to not use them as identifiers for accessors.

    Look at recorder.ignorable_ids.pattern in sahi.properties

  5. Checkbox simulation has fluctuated a bit in the last few builds of
    Chrome. Sahi now assumes Chrome 10+ as default. This is modifiable in
    sahi.properties

    [code]simulation.chrome.explicit_checkbox_radio_toggle=true[/code]

    Change to false if the checkboxes seem to toggle back to original state.

  6. Download the latest version from here:
    https://sourceforge.net/projects/sahi/files/ and do spread the good word. You can tweet about it, or like us on Facebook or write a blog post about it.

    Wish you happy productive testing!

Stable accessors/locators using UI Relations

Posted by | Sahi, stable tests, ui relations, web automation, web testing, xpath | No Comments

Identification of elements in a web interface is one of the toughest challenges of software UI automation. First came accessing by location (x,y coordinates), which quickly faded away due to window resolutions, rendering differences etc. Then came the concept of identification using code structure. XPath became hugely popular;

Reasons being

  1. Automation was only attempted by established developers and they understood XPaths
  2. 5 years back web applications were simple enough to easily look at the DOM and identify XPaths.
  3. Some (silly!) tools adopted and hugely promoted XPaths for want of innovation on that front.

But XPaths quickly became notorious for being unmaintainable and difficult to understand. If test automation was to spread to non-programmer testers, this would be a huge barrier. Tools then tried to move on to css-selectors, which is still complex for the target test automation teams.

So what could be a possible solution? The answer is in the User Interface.

What is often forgotten in the software industry, is that applications are built to satisfy business needs. So whatever the id, XPath or css-selector is, a textbox meant for “loan amount” will always be near some label saying “Loan Amount”. An expand or collapse icon in a tree gets its meaning from the attached “User name” label for that node. These business requirements do not change as often as code or underlying HTML structure. An HTML table may get converted to an ext-js grid with scrollbars, but the cost will still be associated (and aligned) with a product and listed under the heading “Cost”. Items related to each other would be shown inside a box with an appropriate heading.

How can we use this information to identify elements? Use UI relations for identification. Sahi, which has been a pioneer in web-automation innovation, handles it as below:

A textbox meant for “loan amount” becomes

_textbox(0, _near(_label("Loan Amount")))

or

browser.textbox(0).near(browser.label("Loan Amount"))

The cost becomes
_cell(0, _near(_div("My product one")), _under(_div("Cost")))
The expand collapse icon becomes
_image("/tree-node-icon/", _near(_span("Expand me")))

  1. These accessors clearly communicate what the intention of the accessor is, in a straight forward way (within the constraints of programming language constructs).
  2. These also take away the complexity in identifying and stabilizing XPaths, or understanding complex css-selectors, or writing custom javascript loops to accomplish the same thing.
  3. They are quite stable. _near allows for more elements to come between two related elements, _under is spatially aligned. So you can move different elements around on the UI and still have your scripts working properly.

UI Relations are guaranteed to exist in any business application, irrespective of whether you have ids or not.

One argument that comes up is, what if there are two similar elements which satisfy the same condition. While it is still possible to index the similar accessors and uniquely identify them, it seldom happens in a real world application. If you have two textboxes near “Loan amount”, it is going to confuse your end user. User-interfaces do not generally have such anomalies. That said, an added index to the accessor handles that scenario too, if it arises.

There is one other simplification that Sahi does in its accessor APIs. It does not explicitly state what the identifying property is. For example what could have been
_textbox()
is simply given as
_textbox("username") in Sahi.

Why? Because there are very few cases where one textbox has name=”username” and another has id=”username”. Such naming would obviously confuse the web developer forcing him to not do something like this.

Combined with UI relations, Sahi also takes care of automatically waiting for AJAX requests and page loads. This makes for robust scripts which hardly have unexpected failures. Other features like parallel playback of suites, automatic report generation, ant integration etc. make Sahi one of the most advanced web testing tools in the industry.

If you have not tried it yet, download from http://sourceforge.net/projects/sahi/files/ now. You can also use Sahi from inside ThoughtWorks Studios Twist or PushToTest’s TestMaker 6.

September Update

Posted by | Sahi, tyto, update | No Comments

The past month has been very special for us. We delivered Sahi Pro to our customers, and without even publishing about it, we got many inquiries about Sahi Pro. This was something we had not expected, but would like more of.

Given the number of support queries coming in, we had to scale to better serve our customers. So Boopathi M joins our team as a support engineer. With a background in programming and teaching mathematics online, we look forward to utilizing his tutoring capabilities to solve technical issues in Sahi for our customers.

We also managed to have a presence in Java One, thanks to PushToTest‘s generous offer to all its partners to show case themselves. Given that Sahi has started playing a good role in TestMaker’s web automation part, this turned out to be a good point of synergy.

I (Narayan) also participated as one of the panelists in the Birds Of a Feather session on open source testing tools, thanks again to Frank, CEO of PushToTest. (It is amazing what PushToTest is doing to promote open source products. If ThoughtWorks is the breeding ground for open source projects, I would say PushToTest is one of the few companies that helps them bootstrap and become commercially viable.) We realized Sahi is almost unheard of in the Java developer community! So we are coming up with ways to rectify that. If you have suggestions, do let us know.

This month was also great because we got lots and lots of praise for Sahi (read some testimonials). We had 4 instances of Sahi users reporting that they shifted from QTP to Sahi because QTP had problems identifying some web elements, which Sahi could easily identify. Some of them also had problems on QTP’s Windows 7 support.

Selenium continues to annoy us with its presence. We again had 3 different discussions with users who said “We find Sahi to be much easier to use but developers/management (in the US) have heard only of Selenium.” A stackoverflow question has considerably undermined Sahi’s capabilities and slandered DP, one of Sahi’s old and staunch supporters. It was frustrating to know we can’t do much about it. Equally unhelpful is the fact that we will not be able to participate in GTAC 2010 because “the committee reviewed each application with special attention towards contributions to the professional community, among other aspects. We regret to inform you that you have not been short-listed to attend this year’s conference.” We would have loved some discussion with the WebDriver guys.

Our website was hacked twice last month and if you find google search results showing weird titles for Sahi searches, please let us know on the forums or email us.

We have started a facebook page for Sahi, so please do spread the word.

We now have integrations with Test Management tools like XQual, Testuff and Neuvosoft Test Manager, and we will continue to support more. Coming up is integration with QMetry

Things on the roadmap (Oct-Nov):
1) Flex/Flash support(Pro)
2) Simple loadtesting through HTMLUnit (Pro)
3) Integration APIs for Test Management tools (Open and Pro)

We continue with our integrations with PushToTest‘s TestMaker and Test Object Designer, and with ThoughtWorks Studios’ Twist.

We will be starting webinars every two weeks as an introduction to Sahi. The first session is (tentatively) scheduled for 22 October 2010. If interested please email us at support@sahi.co.in

Thanks for reading through. If you have suggestions, queries or advice, please email us at feedback(at)sahi.co.in. Hope to see you next month!

Sahi V3 2010-06-10 released

Posted by | releases, Sahi | 5 Comments

Sahi V3 (2010-06-10) is now available for download. https://sourceforge.net/projects/sahi/

There have been significant improvements and bug fixes in this release.

  • API _under ( /w/browser-accessor-apis ) has been added to locate elements physically under another.
  • API _byXPath has been added to help users from Selenium and other tools move to Sahi.
  • API _row and _option have been modified to be in sync with other APIs. Existing scripts may need to be modified if you use these APIs.

Below is the changelog:

10 Jun 2010
———–


* Bugfixes
Fixed data truncation bug introduced in 30 Apr build
Fixed getText bug which returned ab on FF and a b on IE for a
b
Fixed for   in select option text
Fixed window.opener behaviour for link clicks
Fixed parsing error for $a == $b

* Features added
Added Shiretoko as variant of Firefox
_byXPath added.
For browsers without XPath support,
download the javascript file from http://coderepos.org/share/wiki/JavaScript-XPath
and save the contents in sahi/htdocs/spr /javascript-xpath.js
_under added as a positional relation
Lets identify elements under another element eg. _cell(0, _under(_tableHeader("Status")))
5xx errors are displayed on screen too.
Time taken by each test is displayed in logs.
XHR redirects are excluded from injection
Added Driver.setControllerMode. Takes sahi, java, ruby
_option brought in sync with other APIs.
NOTE: older _option(selElement, value) will not work any more
Replace with _option(value, _in(selElement))
_row brought in sync with other APIs.
NOTE: older _row(tablElement, rowNumber) will not work any more
Replace with _row(rowNumber, _in(tablElement))

Ruby Sahi with Cucumber

Posted by | BDD, Cucumber, Ruby, Sahi | 8 Comments

What is Cucumber?

Cucumber lets software development teams describe how software should behave in plain text. The text is written in a business-readable domain-specific language and serves as documentation, automated tests and development-aid – all rolled into one format.
– From http://cukes.info/

Follow the steps below to get started with Ruby Sahi and Cucumber.

  1. Install Java
  2. Install Ruby
  3. Install cucumber:
    gem install cucumber
  4. Install Sahi proxy: Download Sahi from sourceforge and unzip to some location. (say D:sahi)
  5. Start Sahi:

    cd D:sahiuserdatabin
    start_sahi.bat

  6. Install Sahi Ruby client:
    gem install sahi
  7. Create a file D:testlogin.feature, add the content below and save it.

    Feature: Login
    In order to access the system
    As a user
    I want to be able to login

    Scenario: Login with valid credentials
    Given I am not logged in
    When I try to login with "test" and "secret"
    Then I should be logged in

    Scenario: Login with invalid credentials
    Given I am not logged in
    When I try to login with "test" and "wrongpassword"
    Then I should not be logged in
    And I should be shown error message "Invalid username or password"

  8. Run this feature:

    cd D:test
    cucumber login.feature

    There will be a lot of messages with hints on implementing the right steps.

  9. Implement the steps:

    Create a file D:testlogin.rb, add the content below and save it


    require 'sahi'

    def init_browser()
    #Use the correct paths from your system
    userdata_dir = "D:/sahi/userdata"
    browser_path = "C:\Program Files\Mozilla Firefox\firefox.exe"
    browser_options = "-profile #{userdata_dir}/browser/ff/profiles/sahi0 -no-remote"
    return Sahi::Browser.new(browser_path, browser_options)
    end

    #open the browser at the start
    browser = init_browser()
    browser.open

    #close the browser on exit
    at_exit do
    browser.close
    end

    Given /^I am not logged in$/ do
    browser.navigate_to("/demo/training/index.htm")
    end

    When /^I try to login with "([^"]*)" and "([^"]*)"$/ do |username, password|
    browser.textbox("user").value = username
    browser.password("password").value = password
    browser.submit("Login").click
    end

    Then /^I should be logged in$/ do
    if !browser.button("Logout").exists?()
    raise "Not logged in"
    end
    end

    Then /^I should not be logged in$/ do
    if !browser.submit("Login").exists?()
    raise "Logged in"
    end
    end

    Then /^I should be shown error message "([^"]*)"$/ do |msg|
    value = browser.div("errorMessage").text()
    if value != msg
    raise "Incorrect message: #{value}"
    end
    end

  10. Run and watch the tests complete successfully

    cd D:test
    cucumber login.feature

  11. Done!

Presentation at XP Goa day

Posted by | Function testing, Sahi, XP Goa day | No Comments

Narayan Raman presented on Functional Testing of Web Applications using Sahi at the XP Goa Day in Goa University.

As part of a presentation , we did a small demo on record and playback of a script using Sahi, then refactored the code to be maintainable.

The site under test is available here: /demo/training
The first cut from the recorder came out to be this:


_setValue(_textbox("user"), "test");
_setValue(_password("password"), "secret");
_click(_submit("Login"));
_setValue(_textbox("q"), "2");
_setValue(_textbox("q[1]"), "1");
_setValue(_textbox("q[2]"), "1");
_click(_button("Add"));
_assertExists(_textbox("total"));
_assert(_isVisible(_textbox("total")));
_assertEqual("1150", _textbox("total").value);
_click(_button("Logout"));

This was then refactored into 2 scripts, one containing functions and the other invoking it:


// goa3_included.sah
function login($username, $password){
_setValue(_textbox("user"), $username);
_setValue(_password("password"), $password);
_click(_submit("Login"));
}

function addBooks($numJava, $numRuby, $numPython){
_setValue(_textbox("q"), $numJava);
_setValue(_textbox("q[1]"), $numRuby);
_setValue(_textbox("q[2]"), $numPython);
_click(_button("Add"));
}

function verifyTotal($total){
_assertEqual($total, _textbox("total").value);
}

function logout(){
_click(_button("Logout"));
}

// goa3.sah
_include("goa3_included.sah");

login("test", "secret");
addBooks(2, 1, 1);
verifyTotal(1150);
logout();

The next step was to modify


function addBooks($numJava, $numRuby, $numPython){
_setValue(_textbox("q"), $numJava);
_setValue(_textbox("q[1]"), $numRuby);
_setValue(_textbox("q[2]"), $numPython);
_click(_button("Add"));
}

such that identifiers “q”, “q[1]” and “q[2]” become more meaningful and are independent of their order. Using the _near API, the function becomes:


function addBooks($numJava, $numRuby, $numPython){
_setValue(_textbox("q", _near(_cell("Core Java"))), $numJava);
_setValue(_textbox("q", _near(_cell("Ruby for Rails"))), $numRuby);
_setValue(_textbox("q", _near(_cell("Python Cookbook"))), $numPython);
_click(_button("Add"));
}

We then data drive the whole test by wrapping the various steps into a single function “addAndVerify”, build a 2 dimensional array of values and then invoke “addAndVerify” for each row of values using _dataDrive


// club the functionality into a single function
function addAndVerify($numJava, $numRuby, $numPython, $total){
login("test", "secret");
addBooks($numJava, $numRuby, $numPython);
verifyTotal($total);
logout();
}

// build a 2D array
var $data = [
[2, 1, 1, 1150],
[3, 2, 1, 1650],
[1, 1, 1, 850]]
// automatically invoke addAndVerify for each row in $data.
_dataDrive(addAndVerify, $data);

We concluded the talk with an enthusiastic Q & A session.
Thank you Goa University for being a great host!

ThoughtWorks Studios’ Twist 2.0 with Sahi

Posted by | Agile, Sahi, ThoughtWorks Studios, Twist, Twist 2.0 | No Comments

ThoughtWorks announces Twist 2.0 availability from 31st March 2010:
http://www.prnewswire.com/news-releases/thoughtworks-studios-new-twist-20-provides-collaborative-agile-test-management-85809582.html

Tyto Software has been collaborating with ThoughtWorks Studios to integrate Sahi with Twist and results will be visible in Twist 2.0.

“Twist 2.0 has added Sahi as an additional option for web testing. The main benefit of Sahi is that it abstracts out most difficulties that testers face while automating web applications. Its features include an excellent recorder, platform and browser independence, no XPaths, no waits and multi-threaded playback. In addition, it allows you to identify UI components within the application as you record test scenarios.” Announcing Twist 2.0: Available for download on March 31

ZK testing with Sahi

Posted by | Sahi, ZK, ZKOSS | No Comments

Joseph Neuhaus has written a detailed article on testing ZK applications with Sahi. The article explains how to run Sahi tests headless on a linux machine.

Excerpts from the well written, thorough article:

If you have attempted to create browser-based functional tests with Selenium, or load tests using Grinder, then you will marvel at the simplicity of Sahi.

The Problem
Testing ZK Web Applications can be a challenge with Selenium and Grinder because ZK dynamically generates element IDs, and these testing frameworks identify elements within the rendered Web Page using these IDs. Therefore, once a session has been recorded, it cannot be replayed because the element IDs will change the next time the Web Application is launched. To address this, ZK provides a hook so you can generate your own IDs. This is a great feature to be sure; however, now you’re not testing the application that will be promoted into production. Also, keeping track of “special” test builds of your application increases work and complexity. To make matters worse, some testing frameworks, such as Selenium, require you to install browser plugins to create the recorded browser sessions used for playback. When browser updates occur, you can’t upgrade until the plugins are updated too. More moving parts means more issues maintaining the Test Environment. There must be a better way, and there is. It’s called Sahi.

The Solution
Sahi can record and playback sessions directly on your production ZK Web Application without having to use a custom ID generator. It requires no browser plugins to create recorded sessions to be used for playback. Sahi is pure Java, so it integrates nicely with ANT. The Sahi scripting language is simple and elegant, so there’s no need to break out the XPATH documentation to get your tests running. You can even run your Sahi tests headless using Firefox in an X-Window virtual frame buffer on Linux. In headless mode you can run real browser-based tests on your continuous integration machines without having to be logged in. If you’re testing on windows, you can run your tests on IE, Firefox, Chrome, Safari, and Opera. Despite some idiosyncrasies Sahi seems magical at times, but more importantly it makes testing productive – so productive it’s almost fun!

The full article is available here: http://docs.zkoss.org/wiki/Making_ZK_Functional_Tests_With_Sahi

Joe Neuhaus has over twenty years of experience in software development, systems design, and technical management roles.

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.

Sahi V2 Nightly Unstable Build 2009-04-23 Released

Posted by | releases, Sahi | No Comments

Sahi V2 Nightly Unstable Build 2009-04-23 has been released. (Download)

This build has a few significant improvements. It now uses Rhino 1.6R2 as its Javascript engine.

NOTE that this and further builds need Java 1.5 or greater.

* API _near, similar to _in has been added. Any element can be found relative to another by using _near.
Eg.


_checkbox(0, _near(_span("user name 1")))
_link("delete", _near(_span("user name 1")));

* All Sahi accessor API calls can be set to variables now.
Eg.


_click(_link("click me"));

can be written now as


$ln = _link("click me");
_click($ln);

* Check for visibility of elements is now controlled via element.visibility_check.strict property in sahi.properties. It is set to false by default.

Sahi in DevCamp

Posted by | DCB2, Sahi, talks | No Comments

Presented on Sahi in DevCamp Bangalore held in the ThoughtWorks office. I spoke in the 10.30 slot and was pleasantly surprised by the turnout. Show cased how Sahi can be used to test https and AJAX sites using the example of gmail. The response was encouraging.

Below is the code that was need to automate gmail.


function login($username, $password){
_setValue(_textbox("Email"), $username);
_setValue(_password("Passwd"), $password);
_click(_submit("Sign in"));
}

login("sahi.abcde", "tough123");
_click(_spandiv("Compose Mail"));
_setValue(_textarea("to"), ", ");
_setValue(_textbox("subject"), "important subject");
_rteWrite(_rte(0, _near(_textbox("subject"))), "lots of content");
_click(_spandiv("Send[9]"));
_assertExists(_cell("Your message has been sent. View message"));
_click(_link("Sent Mail"));
_assertExists(_spandiv("To: dummy.email"));
_click(_checkbox(0, _near(_spandiv("To: dummy.email"))));
_expectConfirm("You are about to move the entire conversation to the Trash. Are you sure you want to trash the entire conversation containing your sent message?", true)
_click(_spandiv("Delete[14]"));
_assertExists(_cell("The conversation has been moved to the Trash. Learn more Undo"));
_assertExists(_cell("No sent messages! Send one now!"));
_click(_link("Sign out"));

This was the first cut, of which all lines except those using _near were recorded via the Sahi controller.

I will follow up with a more detailed post on other discussions I had in DevCamp.
Note that _near is available only in the most recent nightly build (2009-04-11)

This nightly release was made for folks at DevCamp who wish to replicate what I demoed.

Sahi – Latest developments

Posted by | Sahi | No Comments

Copy of post on forum: /forums/viewtopic.php?id=261

I had not been active on the Sahi forums (/forums) for sometime. Thanks a ton to StringyLow, tinchie8, lepierrot, pankaj.nith and others for keeping this forum active, and replying to posts.

Meanwhile I have been working on a version of Sahi which attacks one of the basic problems with Sahi.
Scopes of variables, scheduler and normal functions and the the way steps are queued and executed and the way their integrity needs to be maintained across page loads.

The problem had been that the scripts (after parsing) were executed on the browser itself, and when a page unloads, the state of the script’s execution needed to be persisted on the proxy and then resurarected when the next page loaded. While this allowed the ease of using javascript for scripting, when scripts became bigger, the browsers and the proxy had to do a lot more persisting and resurrecting.

As the logical next step, I wanted to move this script execution to the proxy. I now use Rhino, an excellent javascript engine, to execute the scripts on the proxy. Only steps that need to be executed on the browser are sent to the browser. Javascript can still be used for Sahi scripting. Even though the script still is parsed, it is much simpler to understand script execution than it was before. Rhino also comes with a debugger which can prove useful to Sahi script debugging.

The version is slated to be released soon. I am looking for volunteers to test and give me feedback about the new version. If you have existing scripts, the scripts may need to be modified a little to make it work with the new version.
If you are interested, please post back or email me at narayan at sahi.co.in.

Use fully-loaded Sahi Pro FREE for a month. Download Now Request a Demo