【发布时间】:2012-04-24 15:25:03
【问题描述】:
我有一个带有组合框和元素表的网络应用程序。我需要使用 codedUI 编写一个方法,该方法从组合框或表格中选择一个元素,将元素的“名称”作为参数传递是否可能?
如果需要更多信息,请询问我
谢谢
【问题讨论】:
标签: visual-studio-2010 coded-ui-tests
我有一个带有组合框和元素表的网络应用程序。我需要使用 codedUI 编写一个方法,该方法从组合框或表格中选择一个元素,将元素的“名称”作为参数传递是否可能?
如果需要更多信息,请询问我
谢谢
【问题讨论】:
标签: visual-studio-2010 coded-ui-tests
您可以记录您要测试的操作,然后在UIMap.Designer.cs 文件中自定义自动生成的代码来选择您需要的控件。对于您在记录测试时使用的每个控件,CodedUi Test Builder 在此文件中创建一个新类。如果您的控件相似(例如 control1、control2...),请将参数名称分配给该控件的 Search Properties:
public class UIItemWindow : WinWindow
{
public UIItemWindow()
{
#region Search Criteria
//Here assign the paramter to the search properties of the control
this.SearchProperties[WinWindow.PropertyNames.Name] = parameterName;
#endregion
}
#region Properties
public UIItemWindow1 UIItemWindow1
{
get
{
if ((this.mUIItemWindow1 == null))
{
this.mUIItemWindow1 = new UIItemWindow1(this);
}
return this.mUIItemWindow1;
}
}
#endregion
#region Fields
private UIItemWindow1 mUIItemWindow1;
#endregion
}
要了解如何将参数传递给 CodedUI 测试,请查看以下链接:
【讨论】: