簡體   English   中英

將 JTree 與 C# 結合使用並完成測試

[英]Using JTree with C# and Test Complete

我正在編寫一個通過測試完成和 C# 訪問 JTree 的測試。 我附上了一張圖片。 不幸的是,為了公司機密,我不得不把一些文字塗黑。 但基本上是這樣的:

路由規則

  • 2級分支機構
    • 3級選擇

我將 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}

這似乎是該網站所說的這樣做:

https://support.smartbear.com/testcomplete/docs/app-objects/specific-tasks/standard/tree-view/checking-item-state.html#Expanded

難道我做錯了什么? 或者我可以不將值分配給“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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM