If we try addressing an unsupported property of an object's method an error would show up in the log.
To first verify if a property or a method is supported by the given controls element, we can use a specific method of IsSupported
, that is extended by the
aqObject
object.
In this recipe, we will consider an example of using the IsSupported
method.
The following function demonstrates usage of the aqObject.IsSupported
method with the example of the Calculator Plus application:
wText
property outputted to the log, if the same is available in the given controls element.function testPropertySupported() { var wCalc = Sys.Process("CalcPlus").Window("SciCalc"); wCalc.Activate(); var objects = wCalc.FindAllChildren("Visible", true); objects = (new VBArray(objects)).toArray(); for(var i = 0; i < objects.length; i++) { if(aqObject.IsSupported(objects[i], "wText")) { Log.Message(objects[i].wText); } else { Log.Warning("Object '" + objects[i].Name + "' doesn't have wText property"); } } }
With the help of the FindAllChildren
method, we will obtain an array of all the sibling objects of the calculator window. Since the FindAllChildren
method returns an array suite-formatted after Visual Basic, we need to transmute the same to fit the JScript array format with the help of the toArray
method.
Further on in the loop, with the help of the aqObject.IsSupported
method, we check if the wText
property is available for each controls element, and thus we output the value of this property, provided it exists for the given controls element, else a warning occurs related to the missing property of the ith object in the loop.
Property availability validation for an object of a specific method is executed in a similar way.
18.188.154.252