locked
Coded UI Testing Adding assertions on to Control Map ID's that keep changing RRS feed

  • Question

  • Hi all

    Hope someone out there can help me, I am trying to add an assertion on an application.

    I am using Visual Studios 2013, Coded UI test, using the UIMap - Coded UI Test Builder

    I have used the crosshair for the assertion, and I have selected the relevant "area" of the application that I want to add. 

    This "area" is a record of data that has an ID associated with it. When testing multiple times this ID will change and never be the same.

    Unfortunately the Control UI Map linked to this "area" is titled to the associated ID. 

    So If I add an assertion to this and then run a new test, the ID will change and this validation fails because it cannot find the control map. 

    Is there any way round this? I am trying to validate the set of data that is in that record of data, but never the ID. The data will always be in the same area of the screen so wondered if there was a way it could validate an area of the application? 

    I am quite new but will try my best to answer any questions to clarify, but any help would be greatly appreciated. 

    Thanks

    Ryan

    Thursday, December 15, 2016 3:37 PM

All replies

  • Hi Ryan,

    According to your description, you want to operate a control with changing ID. I think you cannot call this control with UIMap. You must get this control with handing code based on other properties (except ID property).

    So we need a condition that with other properties we must be able identify the control. Even though ID property changing all the time.

    If we could not get this control with other properties, wo could get a UITestControl collection, then we could use other specify property to get a correct control. Even though the ID is changing, and whether this ID has a range, if yes, I think we could use this.

    Above is my opinion, but I do not know which project you are testing, web, winform or wpf? If you could share me a sample, I will try my best to help you hand code this.

    Sincerely,

    Oscar


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Proposed as answer by Oscar_Wu Monday, December 19, 2016 7:00 AM
    Friday, December 16, 2016 2:57 AM
  • Hi Ryan/Oscar

    There should be no need to hand code this simply inspect the control and identify an alternative group of unique properties to identify it with then change the search and filter properties to reflect these and remove the Dynamic ID from the search properties.

    You may even be able to get away with simply removing the ID from the search properties as the Coded UI Recorder tends to put a fair bit of redundancy into Search/Filter Properties

    Friday, December 16, 2016 10:16 AM
  • Hi Ryan,

    There are couple of work around that you can try to add assertion. 

    1. Instead of Id see if you can find (InnerText, Name etc.

    2. if you find any near by control that has an Id , InnerText or Name  then use parent child relationship

    like

    Control.GetParent().GetChildren().ElementAt() 

    to reach to the desired control and do assertion on it. You need to add Linq library to use parent child relationship.

    Control relationship doesn't change unless UI changes.

    Example

    Assert.AreEqual("Display Name", SomeControlWithID.GetParent().GetChildrent.ElementAt(0).InnerText, "Failure message");

    • Proposed as answer by Oscar_Wu Wednesday, December 21, 2016 5:15 AM
    Tuesday, December 20, 2016 10:28 PM
  • Hi my friend,

    Please remember to mark any replies that help you resolved issue or doubts, thank you very much.

    Sincerely,

    Oscar


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, December 23, 2016 9:40 AM