Hi
In terms of not using name mapping I have a root JavaScript function called seek which ultimately relies on the TC functions:
testObject.FindChild(arPropNames, arPropValues, depth, refresh);
// and
testObject.FindAllChildren(arPropNames, arPropValues, depth, refresh);
// object signatures of calls to seek look something like
seek(parentObj, criteria)
seek(parentObj, criteria, timoutMs)
seek(parentObj, criteria, timoutMs, depth)
seek(parentObj, criteria, criteria, criteria, timoutMs)
seek(parentObj, criteria, criteria, criteria, timoutMs, depth)
// examples of use
function testSeek(){
var browser = Sys.Browser("chrome");
//simple
var userNameTxt = seek(browser, {idStr: 'ctl00_MainContent_username'});
highlight(userNameTxt);
// find the text box within its parent panel - this would not
// be useful on such a small web page as simple search is very fast
userNameTxt = seek(browser, {
ObjectType: 'Panel',
className: 'log*n',
Visible: 'True'
},
{idStr: 'ctl00_MainContent_username'});
highlight(userNameTxt);
// setting the time out to 0 means the search will only run once if the object is not found
// before searching a second time the time out will be exceeded and the search aborted
userNameTxt = seek(browser, {idStr: 'ctl00_MainContent_username'}, 0);
highlight(userNameTxt);
// limiting the search depth means that this search will fail
// and return the stub object (the user name text box is nested more than two levels from
// under the browser)
userNameTxt = seek(browser, {idStr: 'ctl00_MainContent_username'}, 0, 2);
checkFalse(userNameTxt.Exists);
//using a function instead of an object - rarely needed in practice
function isUserTxtBox(uiObj){
return uiObj.idStr === 'ctl00_MainContent_username';
}
userNameTxt = seek(browser, isUserTxtBox);
highlight(userNameTxt);
}
Other functions are built on top of seek like seekByIdStr, setByProperty, seekInPage - in the active web page.
The library itself is not open source at this stage but the seek function is really a wrapper around TestComplete's FindChild. There is also a bit of parameter munging (using the JavaScript underscore library) to turn JS objects into arrays that can be consumed by FindChild.
You can also use underscore functions to work out what kind of parameters you are dealing with and filter the depth and timeout values, if present, from your criteria objects and functions. This relies on the JavaScript arguments object and underscore functions like: _.isNumber, _isObject and _.filter.
John