2012-08-02 21 views
1

当我录制“登录方案”的测试方法与编码的UI测试,它会产生这样的当我在编码的UI测试更新的UIMap中,UIMap.Designer.cs文件覆盖在我的代码

生成的代码代码

 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)); 
    } 

我更新此代码,让数据驱动源,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)); 
    } 

,我跑的测试方法和它运作良好,但是,当我编辑的UIMap添加未使用的控件,如“Canncel按钮”或任何其他控件 想在这个环节

http://blogs.microsoft.co.il/blogs/shair/archive/2010/08/08/coded-ui-test-tip-4-add-unused-controls-to-ui-map.aspx 的的UIMap了.Designer.cs文件覆盖我的登录方法提前

更新代码Genereated代码

谢谢

+0

我发现复制的方法形成UIMap.Designer.cs到UIMap.cs一个简单的解决方案 1-功能PACK2必须安装方法要更新 2-开放UIMap.uitest 3-把点击它行为并选择“移动代码” 结果: 方法将从UIMap.Designer.cs移动到UIMap.cs – 2012-08-07 03:44:43

回答

6

您不应该编辑* UIMap.Designer.cs文件。这些是自动生成的。这是* UIMap.cs文件的用途,用于不会被覆盖的自定义方法和实现。

这就是为什么Designer文件顶部的注释块指出不要手动编辑它们的原因。

+0

感谢您的帮助 – 2012-08-07 02:55:13

+0

这应该被标记为问题的答案,而不是上面的那个,这是完全错误的。不要编辑自动编码。这是唯一有效的规则。 – mikus 2014-07-07 08:38:16

相关问题