Forum Discussion
Correct... it's not a JavaScript array but it is an object that acts like an array and you can use it as an array. Below is the sample code provided for the method for JavaScript... note it still has options for "length" and the square bracket notation for array elements. For most needs for finding a set of onscreen objects that match a particular set of properties, this is usually sufficient.
Feature requests, BTW, have a different place here on the community, though...
function FindEditbuttons() { var p, w, textBoxes, i; // Obtain the Notepad process p = Sys.Process("notepad"); // Open the Font dialog p.Window("Notepad", "*").MainMenu.Click("Format|Font..."); w = p.Window("#32770", "Font"); // Search for all edit buttons in the Font dialog textBoxes = w.FindAllChildren("WndClass", "Edit", 5).toArray(); // Log the search results if (textBoxes.length > 0) { for (i = 0; i < textBoxes.length; i++) Log.Message("FullName: " + textBoxes[i].FullName + "\r\n" + "Text: " + textBoxes[i].wText); Log.Message("Total number of found edit buttons: " + textBoxes.length); } else Log.Warning("No edit buttons found."); }
Thanks!
Yea I wanted to nitpick because I wanted to organically perform functional programming on it.
I think if they update their docs that'd be okay :)
let list = Array.from(Grid.FindAllChildren(...)) // Use Array.from to convert their obj into an actual array. return list.map(obj=>obj.wText).filter(text=>text!='Error') // convert to array of just obj.wText, then filter it to discard the ones that are not 'Error'.
- tristaanogre7 years agoEsteemed Contributor
Documentation says that it's a "safe array"... a microsoft array data type. Probably has something to do with the code language TestComplete is written in... JavaScript is supported in TC as a scripting language, however, behind the scenes, these objects and functions and methods are running in some other language and, therefore, returns things that are not native to the scripting language of choice.
Related Content
Recent Discussions
- 18 hours agodhundley