Forum Discussion
Hi, thank you for the reply. inputElement is filled with the alias object and parentElement is a property of the inputElement.
I've created a simple test project showing the issue: FindAll.zip
As shown on the previous image, localParent appears to be the same object (the structure of the object), like inputElement, so I'm a bit surprised FindAll does not work with it. Any idea how to access the object properly?
Here's the issue - the same code, just commented out line 3
function GetAllButtonsFromAlias(aliasItem)
{
//var parentElement = aliasItem.parentElement;
var buttons = aliasItem.FindAll("ObjectType", "Button", 100);
buttonsArray = buttons.toArray();
Log.Message(`Number of buttons on page, using NameMapping ${buttonsArray.length}`);
}
function test1()
{
//GetAllButtonsFromAlias(Aliases.browser.pageCssButtons.buttons.Parent);
Log.Message(Aliases.browser.pageCssButtons.buttons.parentElement.nodeName);
}
When calling parentElement (line 12) it is retrieving the buttons' parent element, which is <p> (highlighted in yellow)
Aliases.browser.pageCssButtons.buttons highlights "Default Button" for meThe element <p> does not appear in the Object Browser
As mentioned in the documentation,
Use FindAll to search for all objects that have the specified values of the specified properties. The search is performed in the object hierarchy displayed in the Object Browser panel starting from the testedObj object and continuing down the hierarchy to the specified depth.
Hence, FindAll does not work on <p> element.
If I uncomment line 11 and comment line 12, and use Parent (highlighted in yellow) instead of parentElement, then 61 buttons are returned (highlighted in green)
To make your function return the appropriate number of items, don't use line 3, but do pass parameters like "Aliases.browser.pageCssButtons.buttons" or "Aliases.browser.pageCssButtons.buttons.Parent".
Hopefully, this should also resolve your issue with your other post relating to "FindAll returns only one (first) element"