FindChild method fails intermittently when called from keyword test
- 6 years ago
Hi,
> fails 7 out of 10 times
Does failure and pass occur for exactly the same data? Or just with different data the function may pass or fail ?
It is difficult to provide an answer without seen how the function is called (I am interested in exact parameters' values). I am wondering because, for example, if you search by more than one parameter, then you must pass arrays for properties and values, but if the actual paremeter is, say, 'Param1, Param2' string then it will not be resolved to the array even with the help of eval() function.
Another note:
var child_object = parentObject.FindChild(propertiesArray, valuesArray, depth, true); // This will find the child at any level while((!child_object.Exists) && (counter < 90)){ //This will wait until child_object exists ...
This code will not work as expected, because if child_object is not found by .FindChild() at the moment of search, the returned value will be an empty stub object with .Exists property equal to false. And the object will not be re-evaluated even if the sought for object appears later. So while loop is useless here.
The correct way is
either to use the .FindChildEx() method instead of the .FindChild()
or use the loop like this:
var child_object; do { child_object = parentObject.FindChild(propertiesArray, valuesArray, depth, true); if (!child_object.Exists) Delay(500); } while((!child_object.Exists) && (counter < 90));
The first approach will just wait for the object to appear within the specified timaout while the second one allows some additional actions to be done while waiting. For example, some confirmation window that must be closed before the sought for object appears can be processed with the latter approach.
P.S.
> // This will find the child at any level
Actually, not at 'any level' but at the level up to the 'depth' depth.
Incorrect commenting might appear to be even worse than absence of the such at all... :)