[英]Generate an array of objects from all the rows and columns in WPF grid control on a coded UI test C#
嘗試從WPF網格生成一個對象數組,在Visual Studio 2015編碼的UI測試中獲取所有行及其相應的單元格數據,以使用網格控件測試桌面應用程序。
基本上,我正在嘗試搜索,定位和單擊WPF網格上的單元格,基於我應該存在於某個特定單元格中的字符串值。
這是我嘗試獲取數據的ac #test方法:
[TestMethod]
public void GridInteractions()
{
#region Variable Declarations
//This is my grid control from 'UIMap.uitest' control repository
var gridControl = this.MainWindow.MainPanel.GridPanel;
#endregion
}
GetChildren
方法將返回一個UITestControlCollection
,其中包含控件的所有直接后代。 你想要的項目可能是他們的后代(后代的后代......)。 可以通過在代碼中添加以下內容來找到它們:
UITestControlCollection children = gridControl.GetChildren();
可能值得使用GetChildren
從gridControl
進行遞歸下降以獲取所需的值。 或者,如果您知道控件的確切層次結構,那么如果只需要兩個級別,則可以使用該樣式的代碼:
UITestControlCollection children = gridControl.GetChildren();
foreach ( UITestControl child in children )
{
UITestControlCollection grandChildren = child.GetChildren();
foreach ( UITestControl grandChild in grandChildren )
{
... process the grandchild ...
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.