2012-08-02 22 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

相關問題