Hi all,
so... I have created my own "Exists solution" . I wrote function which divide full path of object identification (from Sys to the end) to individual parts, which I evaluate one by one.
Individual object parts must be divided by using ";" delimited since "." can be commonly present inside brackets. So you need to adjust it accordingly like this:
var objDefinition = Find("ObjectIdentifier","iexplore");Find("URL","http://newtours.*");FindChildByXpath("//input[@name='userName']")
following function returns mapped object - if object (including all its parents) is/are found - or null object - if not. Of course... if object is not found, testComplete still runs which was one of the main points :-).
function objGet (objDefinition)
{
objExistResult = false;
var objExistResult = true;
var objArray = objDefinition.split(";");
var obj = "Sys";
mappingLoop:
for (var i in objArray)
{
switch (aqString.SubString(objArray, 0, aqString.Find(objArray, "(")))
{
case "Find":
if (eval(obj+"."+objArray).Exists)
{
obj = obj+"."+objArray;
}
else
{
objExistResult = false;
break mappingLoop ;
}
break;
case "FindChildByXpath":
if (eval(obj+"."+objArray) != null)
{
obj = obj+"."+objArray;
}
else
{
objExistResult = false;
break mappingLoop ;
}
break;
}
}
if (objExistResult == true)
{return eval(obj);}
else
{return null}
}
you can use following function (which uses one above), and returns true if object is found, otherwise false:
function objExists (objDefinition, syncTimeLimit) {
for (var attempt = 1; attempt <= syncTimeLimit; attempt++)
{
if (objGet (objDefinition) != null)
{
return true;
}
else
{
aqUtils.Delay(1000);
}
}
return false;
}
This approach currently supports only methods
Find and
FindChildByXpath, but another can be integrated (however this should be quite sufficient for most situations).
Lukas