moh*_*eeh 1 automation coded-ui-tests
当我使用Coded UI测试记录"Login Scenario"的测试方法时,它会生成这样的代码
生成的代码
public void LoginMethod()
{
#region Variable Declarations
WinEdit uIItemEdit = this.UIDiagnosoftVIRTUEWindow.UIItemWindow.UIItemEdit;
WinEdit uIItemEdit1 = this.UIDiagnosoftVIRTUEWindow.UIItemWindow1.UIItemEdit;
WinComboBox uIItemComboBox = this.UIDiagnosoftVIRTUEWindow.UIItemWindow2.UIItemComboBox;
WinButton uIConnectButton = this.UIDiagnosoftVIRTUEWindow.UIConnectWindow.UIConnectButton;
#endregion
// Type 'username' in 'Unknown Name' text box
uIItemEdit.Text = this.LoginMethodParams.UIItemEditText;
// Type '********' in 'Unknown Name' text box
Keyboard.SendKeys(uIItemEdit1, this.LoginMethodParams.UIItemEditSendKeys1, true);
// Select 'facility' in 'Unknown Name' combo box
uIItemComboBox.SelectedItem = this.LoginMethodParams.UIItemComboBoxSelectedItem;
// Click 'Connect' button
Mouse.Click(uIConnectButton, new Point(64, 14));
}
Run Code Online (Sandbox Code Playgroud)
我更新此代码以允许数据驱动源,CSV文件,其中包含用户名,密码,....这里是更新的代码
更新的代码
public void LoginMethod(string username,string password,string facility)
{
#region Variable Declarations
WinEdit uIItemEdit = this.UIDiagnosoftVIRTUEWindow.UIItemWindow.UIItemEdit;
WinEdit uIItemEdit1 = this.UIDiagnosoftVIRTUEWindow.UIItemWindow1.UIItemEdit;
WinComboBox uIItemComboBox = this.UIDiagnosoftVIRTUEWindow.UIItemWindow2.UIItemComboBox;
WinButton uIConnectButton = this.UIDiagnosoftVIRTUEWindow.UIConnectWindow.UIConnectButton;
#endregion
// Type 'msameeh' in 'Unknown Name' text box
uIItemEdit.Text = username;
// Type '{Tab}' in 'Unknown Name' text box
uIItemEdit.Text=password;
// Select 'diagnosoft.com' in 'Unknown Name' combo box
uIItemComboBox.SelectedItem = facility;
// Click 'Connect' button
Mouse.Click(uIConnectButton, new Point(64, 14));
}
Run Code Online (Sandbox Code Playgroud)
我运行测试方法,它运作良好但当我编辑UIMap添加未使用的控件,如"Canncel按钮"或任何其他控件,如在此链接
UIMap http://blogs.microsoft.co.il/blogs/shair/archive/2010/08/08/coded-ui-test-tip-4-add-unused-controls-to-ui-map.aspx. Designer.CS文件覆盖我的Login方法使用Genereated代码更新代码
提前致谢
您不应该编辑*UIMap.Designer.cs文件.这些都是自动生成的.这是*UIMap.cs文件的目的,用于不会被覆盖的自定义方法和实现.
这就是为什么Designer文件顶部的注释块指出不要手动编辑它们.
| 归档时间: |
|
| 查看次数: |
3494 次 |
| 最近记录: |