View source | Discuss this page | Page history | Printable version   

ERP 2.50:Automated Testing/Old Sahi Scripting


Warning.png

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


Contents

SAHI scripting

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

Common functions like

...
login(User,Password)
...

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.

Example:

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("folderCell2_155"));
_click(_cell("folderCell2_161"));
_click(_cell(_table("window145"), 0, 1));

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

//3. Click Save
_click(_byId("SaveButton"));
...


Verifying

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:

...
_click(_byId("ProcessButton"));
_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.


Limitations

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:

...
_setValue(_byId("fileTag"),"/opt/sahi/data/example.txt");
...

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 "http://wiki.openbravo.com/wiki/ERP_2.50:Automated_Testing/Old_Sahi_Scripting"

This page has been accessed 6,057 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.