我在Visual Studio中的UI編碼的UI測試2010 我想寫一個代碼將:編碼的UI控件發現
- 來到一個窗口上的控件和子窗口這是按鈕,grid,label
- 用代碼中的控件名稱編寫一個uimap。
對於啓動它,我已經寫了以下內容:
public void CodedUITestMethod1()
{
string uiTestFileName = @"D:\dev11\ConsoleApplication1\TestProject1\UIMap.uitest";
UITest uiTest = UITest.Create(uiTestFileName);
Microsoft.VisualStudio.TestTools.UITest.Common.UIMap.UIMap newMap = new Microsoft.VisualStudio.TestTools.UITest.Common.UIMap.UIMap();
newMap.Id = "UIMap";
uiTest.Maps.Add(newMap);
GetAllChildren(BrowserWindow.Launch(new Uri("http://bing.com")), uiTest.Maps[0];);
uiTest.Save(uiTestFileName);
}
private void GetAllChildren(UITestControl uiTestControl, Microsoft.VisualStudio.TestTools.UITest.Common.UIMap.UIMap map)
{
foreach (UITestControl child in uiTestControl.GetChildren())
{
map.AddUIObject((IUITechnologyElement)child.GetProperty(UITestControl.PropertyNames.UITechnologyElement));
GetAllChildren(child, map);
}
}
但它插入到遞歸循環,不會結束。
任何人都可以幫助我嗎?
您是否添加了任何調試或工具來確定您在foreach循環的每次迭代中查看哪些控件?只是從它看,我不會指望它進入無限遞歸。 – 2011-06-01 12:14:02