简体   繁体   中英

Passing parameters through scripting

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
   );
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM