0

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?

1 Answer 1

0

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
   );
}
Sign up to request clarification or add additional context in comments.

4 Comments

I tried that and it did not work as per my example above.
What exactly do you mean by "did not work"? Do you get an error message (what does it say)? Does it click a different item?
'object' is a reserved word. Use another name for the first parameter. I would use another word for the 'property' parameter as well.
@DmitryNikolaev: I believe it's not. Reserved Words in VBScript 5.5 and JScript 5.5. Also, object wouldn't conflict with the built-in Object, because JScript is case-sensitive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.