View source | Discuss this page | Page history | Printable version   
Main Page
Upload file
What links here
Recent changes

PDF Books
Show collection (0 pages)
Collections help


ERP 2.50:Automated Testing/Old Sahi Scripting


This document has been deprecated. It is going to be removed from this Wiki shortly.


SAHI scripting

Functions are grouped in a separated file, library.sah.

Common functions like


must be used instead of including on script specific commands.

As an extension to original test cases, comments for every test case step and corresponding scripts statements must be added.


Original Testcase

1. Go Menu > Submenu > Window
2. Fill field_A with XXX value
3. Click Save

Script Commented

//1.Go Menu > Submenu > Window
_click(_cell(_table("window145"), 0, 1));

//2. Fill field_A with XXX value
_setValue(_textbox("field_A"), "XXX");

//3. Click Save


In order to verify if a script execution is correct or not, checkpoints should be placed at critical points.

For example, if a success message appears after completing a process, the script should look like this:

_assertContainsText(_getGlobal("processCompleted"), _byId("messageBoxIDMessage"));

Note that the text of the message is managed trough a global variable, so the same script can manage different languages.


There are a couple of tasks that can not be scripted. For this reason, a full unattended run is not possible yet.

File uploading

Because of a Sahi issue (in fact a Javascript security feature) FILE html tags can not be completed by script, so a command like this:


will have no effect. Sahi provides a workaround, so the upload will look like this:

_setFile(_file("fileTag"), "/opt/sahi/data/example.txt");

Actually, this statement do not fill the FILE tag the value but the file will be added on the HTTP Request after submitting the FORM. So, if the window has a validation for asking the FILE as mandatory, it will not work properly.

Current workaround

User interaction is required to fill the value by hand. The script alerts the user and then waits until the field has text:

_alert("User intervention required\nPlease fill the FileTag field");
_wait(90*1000, _file("fileTag").value!="");

Accessing different ports

Because of proxy used by Sahi, if access to a specific port is required, it may not work (sometimes it works, currently under analysis).

Non web tasks

As part of some test cases it's required to do some extra tasks, like copying a file onto specific folder, or launching an Ant task.

Current workaround

This tasks had to be performed by hand. When possible, all tasks will be grouped at start like an "environment initial setting".

Retrieved from ""

This page has been accessed 4,067 times. This page was last modified on 3 April 2012, at 11:00. Content is available under Creative Commons Attribution-ShareAlike 2.5 Spain License.