Locked Need code to reinitialize UIMAP

  • Thursday, September 13, 2012 6:23 PM
     
     

    I have Visual Studio 2010 Ultimate.  After recording, the replay was running as intended.  However after enhancing the script fails to recognize objects which were recognized prior modification of UIMAP.  These cause script to fail replay.

    Could anyone kindly provide code to re-initialize the UIMAP?

All Replies

  • Friday, September 14, 2012 4:28 AM
    Moderator
     
     

    Hello LearnVSTest,

    Thank you for your post.

    If you modify the UIMap.Designer.cs file, any code changes you make in the UIMapDesigner.cs file will be overwritten every time you generate code using the UIMap - Coded UI Test Builder. For example, if you have to modify a recorded method, you must copy it to UIMap.cs file and rename it. The UIMap.cs file can be used to override methods and properties in the UIMapDesigner.cs file. You must remove the reference to the original method in the Coded UITest.cs file and replace it with the renamed method name.

    During the Playback, Coded UI first searches for the object having all the specified search properties using ‘AND’ and then one by one it searches with filter properties using ‘OR’ and returns the resultant UI Object.

    If you refactor a control for example changing its property, you need to add the refactored control to the UIMap by using the Coded UI Test Builder.

    And in the UIMap.cs file, you have to add a constructor and specify the SearchProperties property of the control to use the new property.

    The article about Walkthrough: Creating, Editing and Maintaining a Coded UI Test may help you.

    I hope it can help you.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us

  • Friday, September 14, 2012 1:28 PM
     
     

    Thank Amanda for response.

    I looked through the link you provide but it didn't help. 

    Here what I did:

    1) I recorded "launching IE" and entered URL to the application

    2) I recorded "Login" - entered uid/pwd

    3) Replaying was running fine

    4) I added custom methods to launch and login in the Uimap.cs

        when run the script stated that objects at the login field is not recognize.

    What is the cause? What can be the solution?

    below were added to uimap.cs

    public void LaunchWebsite(string url)
            {
                BrowserWindow.Launch(new Uri(url));
            }


            public void LoginYahooMail(string Yuid, string Ypwd) {
               
                HtmlEdit YUserID = this.UIYahooMailThebestwebbWindow.UIYahooMailThebestwebbDocument.UIYahooIDEdit;
                HtmlEdit YUserPwd = this.UIYahooMailThebestwebbWindow.UIYahooMailThebestwebbDocument.UIPasswordEdit;
                HtmlControl YLoginB = this.UIYahooMailThebestwebbWindow.UIYahooMailThebestwebbDocument.UISignInButton;

                YUserID.Text = Yuid;
                YUserPwd.Text = Ypwd;
                Mouse.Click(YLoginB);
            }

  • Monday, September 17, 2012 8:54 AM
    Moderator
     
     Proposed

    Hello LearnVSTest,

    Based on your custom methods, I think that you just give values to the YUserID and YUserPwd. But you don’t accomplish to type the value in the edit control.

    If so, I advise that you can try to use the SendKeys method to perform a keyboard action to check if it helps:

    Keyboard.SendKeys(textBoxDestination, @"C:\Temp\Output.txt");

    About more detailed information, you can see: Verifying Code by Using Coded User Interface Tests

    In addition, you can refer to the article: SendKeys Method

    I hope it can help you.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us

  • Wednesday, September 19, 2012 6:31 AM
    Moderator
     
     

    Hello LearnVSTest,

    What about your issue now? Have you resolved it?

    Would you mind letting us know the result of the suggestion?

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us

  • Thursday, September 20, 2012 10:19 AM
    Moderator
     
     

    Hello LearnVSTest,

    I will mark the reply as answer, if you find it no help, you can feel free to unmark it.

    Thanks,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us

  • Friday, September 21, 2012 5:47 AM
    Moderator
     
     

    Hello LearnVSTest,

    What about your issue now? Have you resolved it?

    If you have resolved it, you can share your solutions & experience here. It will be very beneficial for other community members who have similar questions.

    If not, you can let us know the result of suggestion and give us an example of what you are doing.

    Best regards,


    Amanda Zhu [MSFT]
    MSDN Community Support | Feedback to us