Using Testcomplete (javascript) for our automation.
I have created a function:
function SelectDropdownBoxItem(object, property, item)
{
var dropDown = eval(object + "." + FindChild(property, item, 5));
dropDown.Click();
}
Also tried without using eval...
When I call the method using something like this:
var AutoAddressSuggestionList = Aliases.b.pageGuidewireClaimc.panelBoundlist.AddressSuggestionList;
SelectDropdownBoxItem(AutoAddressSuggestionList,"contentText","1 Something Street*");
I get an error "Object Expected"... I have no idea why, because when I run this method without parameterizing it everything works.
Any ideas?
No need for eval
here; you can call the method directly on the object:
var dropDown = object.FindChild(property, item, 5);
Also, it's a good idea to check that the list item was actually found:
if (dropDown.Exists) {
dropDown.Click();
}
else {
Log.Error(
"Drop-down list item was not found.",
"Object: " + object.FullName + "\r\n" +
"Item : " + item
);
}