Search code examples
jscripttestcomplete

TestComplete Objects - Enumerate properties


For the TestComplete objects of processes, windows and controls on the screen - is there a way to enumerate and print out all the properties. I tried the following code and I get a runtime exception:-

var deskObj = Sys.Desktop; //TC Desktop Object
var normObj = {a:1, b:2, c:3}; //Normal JScript Object

for (var prop in normObj) 
{
    Log.Message(normObj[prop]); //1, 2, 3 
}

for (var prop in deskObj) //Runtime error - Object doesn't support this action
{
    Log.Message(deskObj[prop]); 
}

This leads me to believe that TC Objects are not quite JScript objects - so is there a way to convert these to JScript Objects.


Solution

  • That's right: objects from the Sys tree (the object tree in the Object Browser) are special COM wrappers for actual application objects. They are not common JScript objects.

    To get the list of properties and methods of such TestComplete objects, you can use the GetProperties and GetMethods methods of the aqObject object. You can find sample code within the corresponding help topics.