Click Object based on name
- 6 years ago
Hi,
As Lino (LinoTadros) suggested. You should use eval()/evaluate() function whatever is provided by the scripting language of your test project.
Sample untested pseudo-code:
var mainMenu = Aliases.browser.website.clickMenu;
// open menu, so its sub-items are generated
mainMenu.HoverMouse();
var subitemsCount = mainMenu.FindAllChildren('ObjectIdentifier', 'Panel').length;
for (var i = 0; i < subitemsCount; i++)
{
mainMenu.HoverMouse(); // required for the second and up loop iterations to open menu items
var str = 'var submenuItem = ' + mainMenu.AliasedName + '.Panel(' + i + ')'; // should resolve to e.g. "var submenuItem = Aliases.browser.website.clickMenu.Panel(0)"
eval(str); // this will resolve Panel object and assign it to the submenuItem variable
submenuItem.Click();
// ...
}