Visual Studio2010でUIコード化されたUIテストがあります。次のようなコードを記述したいと思います。
- ボタン、グリッド、ラベルであるウィンドウと子ウィンドウのすべてのコントロールを検出します
- コード内のコントロールの名前であるidを使用して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);
}
}
しかし、それは再帰ループに挿入され、それを終了しません。
誰か助けてもらえますか?