ERP 2.50:Automated Testing/Old 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.
1. Go Menu > Submenu > Window 2. Fill field_A with XXX value 3. Click Save
... //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")); ...
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.
There are a couple of tasks that can not be scripted. For this reason, a full unattended run is not possible yet.
... _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.
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.
This tasks had to be performed by hand. When possible, all tasks will be grouped at start like an "environment initial setting".