[英]Passing parameters through scripting
Using Testcomplete (javascript) for our automation. 使用Testcomplete(javascript)实现自动化。
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; 这里不需要
eval
; 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
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.