【发布时间】:2011-05-29 07:13:57
【问题描述】:
我在 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);
}
}
但它插入到递归循环中并没有结束它。
谁能帮帮我?
【问题讨论】:
-
您是否添加了任何调试或工具来确定您在 foreach 循环的每次迭代中查看的控件?光看它,我不认为它会进入无限递归。
标签: c# coded-ui-tests