[英]Using JTree with C# and Test Complete
我正在编写一个通过测试完成和 C# 访问 JTree 的测试。 我附上了一张图片。 不幸的是,为了公司机密,我不得不把一些文字涂黑。 但基本上是这样的:
路由规则
我将 JTree 放入 C# var(称之为“树”)。 我可以通过做轻松扩展和折叠
tree["DblClickItem"]("Routing Rules"); // expand/collapse top branch
tree["DblClickItem"]("Routing Rules|Level 2 branches"); // expand/collapse second-level
tree["ClickItem"]("Routing Rules|Level 2 branches|level 3 selections") // select item
效果很好。 但是当我试图确定某些东西是否被扩展时,就像这样
var expanded = tree["wExpanded"]("Routing Rules");
这给出了一个例外
_innerException {"Unable to find the object wExpanded(\"Routing Rules\"). See Details for additional information.\r\n<html><body><p>The object with the specified attributes does not exist.</p><p style=\"margin-top: 12px;\"><a href=\"aqa-help://2202\">Possible causes of the error</a></p></body></html>"} System.Exception {System.Runtime.InteropServices.COMException}
这似乎是该网站所说的这样做:
难道我做错了什么? 或者我可以不将值分配给“var”并且必须在 if() 语句中使用它吗?
C#Script(不是 C#)被描述为专为弃用功能而设计的“遗留语言”, 不推荐用于新项目。
“ wExpanded ”属性已过时,仅包含在 TestComplete 中以实现向后兼容性。 此外,它专为 win32TreeView 对象而不是 JTree 对象设计。
最好使用Item对象 - 它被设计为跨各种应用程序工具包的通用接口,并且它具有“ Expanded ”属性,在 C#Script 中如下所示;
// Setting items within the tree using wItem->Item
var routingRules = tree["wItems"]["Item"]("Routing Rules");
// Lower level objects use wItems->Item->Items->Item
var L2Branches = routingRules[Items][Item]("Level 2 branches");
Log["Message"](routingRules["Expanded"]); // returns True or False
var isExpanded = routingRules["Expanded"];
Log["Message"]("value of isExpanded",isExpanded);
或者在 Javascript 中;
// Setting items within the tree using wItem->Item
var routingRules = tree.wItems.Item("Routing Rules");
// Lower level objects use wItems->Item->Items->Item
var L2Branches = routingRules.Items.Item.("Level 2 branches");
Log.Message(routingRules.Expanded); // returns True or False
var isExpanded = routingRules.Expanded;
Log.Message.("value of isExpanded",isExpanded);
TestComplete 文档包含有关“ wExpanded ”属性、 “ Item ”对象接口和它提供访问权限的JTreeItem 属性的更多信息,包括“ Expanded ”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.