locked
when i update UIMap in coded UI test , the UIMap.Designer.cs file overwrite on my code??? RRS feed

  • Question

  • when i record a test method for "Login Scenario" with Coded UI test , it generates code like this

    Generated Code

     

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

    i update this code to allow Data Driven Source ,CSV file which contains username,password,.... here is the updated code

    Updated Code

     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 '**********own 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));    }

    and i run test method and it works well But when i edit the UIMap to add unused controls like "Canncel button" or any other controls like in this link

    http://blogs.microsoft.co.il/blogs/shair/archive/2010/08/08/coded-ui-test-tip-4-add-unused-controls-to-ui-map.aspx

    the UIMap.Designer.CS file overwrites my Login method Updated code with Genereated code

    Thanks in Advance

    Thursday, August 2, 2012 11:59 AM

Answers

All replies

  • You should never write code to a *.Designer.cs file in Visual Studio, these files are usually automatically generated by something.  Included is also a UIMap.cs file, so if you want to modify any of the code in UIMap.Designer.cs then you should copy the methods over to UIMap.cs first, and then rename them to avoid naming conflicts.  Better, if you have Feature Pack 2 then you can open the UIMap.uitest file, right-click the method you want to modify and click "Move Code."  This will automatically move the method to the UIMap.cs file.

    Anything you change in UIMap.Designer.cs is going to be overwritten by the code generation so you should move it to UIMap.cs.


    --Marcus

    • Proposed as answer by Aditya_msft Friday, August 3, 2012 5:49 AM
    Friday, August 3, 2012 12:24 AM
  • If you have Coded UITest Editor, you can move recorded methods to UIMap.cs file very easily;

    You can get Coded UITest editor

    a. Visual Studio 2010 Feature Pack 2  (in case you are using Visual Studio 2010 SP1)

    http://msdn.microsoft.com/en-us/library/gg269474.aspx

    b. Visual Studio 2012 Ultimate RC  

    http://www.microsoft.com/visualstudio/11/en-us

    Thanks


    Aditya Kumar Agrawal (MSFT)

    Friday, August 3, 2012 5:49 AM