18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Function not defined
I am trying to execute the following script, but I get a Javascript error in that my "checkItems" function is not defined. I cannot figure this out and it's driving me nuts! I commented out the entire function, but I still get the error. The _log functions display the messages, so I think the hangup occurs when I pass in the "myScript" object into "checkItems".
<browser>
function screenCheck(target)
{
return _assertExists(target);
}
function checkItems(arraylist)
{
// outerloop:
// for (var i=0;i<arraylist.length;i++)
// {
// var $executor = false;
// _set($executor, screenCheck(arraylist.checkElement));
// if (_condition($executor == false))
// {
// _log("screenCheck failed", "error");
// break outerloop;
// }
// else
// {
// for (var j=0;j<arraylist.length;j++)
// {
// for (var k=0;k<arraylist.actions.length;k++)
// {
// if (_condition(arraylist.actions[k] == null))
// {
// break;
// }
// else
// {
// _click(arraylist.actions[k]);
// }
// }
// }
// }
// }
}
function Script(checkElement, action1, action2, action3, action4, action5)
{
this.checkElement = checkElement;
var list = new Array(5);
list[0] = action1;
list[1] = action2;
list[2] = action3;
list[3] = action4;
list[4] = action5;
this.actions = list;
}
</browser>
var $a = "";
_set($a, _image("ctl00_ContentPlaceHolderMain_btnActivities"));
var $b = "";
_set ($b, _image("ctl00_ContentPlaceHolderMain_btnActivities"));
var $c = "";
_set($c, _submit("Add an activity"));
var myScript = new Array(1);
_log("array initialized", "success");
myScript[0] = new Script($a, $b, $c);
_log("calling Script", "success");
checkItems(myScript);
<browser>
function screenCheck(target)
{
return _assertExists(target);
}
function checkItems(arraylist)
{
// outerloop:
// for (var i=0;i<arraylist.length;i++)
// {
// var $executor = false;
// _set($executor, screenCheck(arraylist.checkElement));
// if (_condition($executor == false))
// {
// _log("screenCheck failed", "error");
// break outerloop;
// }
// else
// {
// for (var j=0;j<arraylist.length;j++)
// {
// for (var k=0;k<arraylist.actions.length;k++)
// {
// if (_condition(arraylist.actions[k] == null))
// {
// break;
// }
// else
// {
// _click(arraylist.actions[k]);
// }
// }
// }
// }
// }
}
function Script(checkElement, action1, action2, action3, action4, action5)
{
this.checkElement = checkElement;
var list = new Array(5);
list[0] = action1;
list[1] = action2;
list[2] = action3;
list[3] = action4;
list[4] = action5;
this.actions = list;
}
</browser>
var $a = "";
_set($a, _image("ctl00_ContentPlaceHolderMain_btnActivities"));
var $b = "";
_set ($b, _image("ctl00_ContentPlaceHolderMain_btnActivities"));
var $c = "";
_set($c, _submit("Add an activity"));
var myScript = new Array(1);
_log("array initialized", "success");
myScript[0] = new Script($a, $b, $c);
_log("calling Script", "success");
checkItems(myScript);