我在 Visual Studio 2010 中有一个 ui 编码的 ui 测试。我想编写一个代码,它将:
- 发现窗口和子窗口上的所有控件,即按钮、网格、标签
- 编写一个 uimap,其 id 是代码中控件的名称。
为了开始它,我写了以下内容:
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);
}
}
但它插入到递归循环中并且不会结束它。
谁能帮我?