locked
Coded UI - Search for a dynamically generated ID on a page and verify RRS feed

  • Question

  • My coded ui test will generate an ID on one page and uses that id to verify on another page.

    How to capture the properties of the dynamically generated ID to create an object. (I am hand coding)



    BK

    Thursday, June 12, 2014 3:50 PM

Answers

  • BK,

    I guess you are talking about a field which is generating a dynamic value, known as ID in your application. To use that property in another page is very simple. First, you will have to extract that property from the current page and store it in a variable. After navigating to next page, you can use that variable value as required.

    Let us assume that the ID property is generated in a read-only textbox, which you have added in your UI Map and its instance is UIMap.Window.Page.IDEdit

    // ....Code till the time the ID control value is generated
    {}
    
    // Read ID value
    string expectedId = UIMap.Window.Page.IDEdit.Text; // The same property used to set the text can be used to get the current text... This is application to all the controls including Labels and Divs etc...
    
    // Now the code that performs other actions and navigates to another page...
    {}
    
    // Now another textbox value is there, you want to verify that the value is same as Id value generated in previous page...
    // string actualId = UIMap.Window.Page2.IDEdit2.Text;
    
    // Assert
    Assert.AreEqual(expectedId,actualId,"Compare");

    TejasJ.

    • Marked as answer by BKK9 Tuesday, June 17, 2014 4:54 PM
    Friday, June 13, 2014 1:19 PM

All replies

  • Hi,

    I don’t understand what is the meaning of "the properties of the dynamically generated ID" and "create an object". As far as I know, ID is not a normal control, it should be not have any properties. Could you please provide us more detail information about the ID? Which object did you want to create? Why did you create an object? We will focus on them to help you.

    As far as I know, Coded UI test is primarily used for validation controls. Whether the ID is within a control on the page and you want to get it and then use it to verify another page? If yes, you can capture the ID through Text property.

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, June 13, 2014 8:49 AM
  • Hi BKK9

    Essentially you'll need to identify Search Properties and Filters which Identify the control other than the Dynamically Generated Property Value.  Then pull it out and compare later.

    Friday, June 13, 2014 12:46 PM
  • BK,

    I guess you are talking about a field which is generating a dynamic value, known as ID in your application. To use that property in another page is very simple. First, you will have to extract that property from the current page and store it in a variable. After navigating to next page, you can use that variable value as required.

    Let us assume that the ID property is generated in a read-only textbox, which you have added in your UI Map and its instance is UIMap.Window.Page.IDEdit

    // ....Code till the time the ID control value is generated
    {}
    
    // Read ID value
    string expectedId = UIMap.Window.Page.IDEdit.Text; // The same property used to set the text can be used to get the current text... This is application to all the controls including Labels and Divs etc...
    
    // Now the code that performs other actions and navigates to another page...
    {}
    
    // Now another textbox value is there, you want to verify that the value is same as Id value generated in previous page...
    // string actualId = UIMap.Window.Page2.IDEdit2.Text;
    
    // Assert
    Assert.AreEqual(expectedId,actualId,"Compare");

    TejasJ.

    • Marked as answer by BKK9 Tuesday, June 17, 2014 4:54 PM
    Friday, June 13, 2014 1:19 PM
  • Hi Tejas, you are right I tried to capture the value generated dynamically but not able to. See the attached image - properties for the object I am trying to capture. I don't want to capture the displaytext or innertext because the number is generated dynamically it will change for each run.

    


    BK

    Tuesday, June 17, 2014 3:43 PM
  • I used top and left and it worked but not sure if this works on another system or if the screen resolution changes. Please let me know. Thanks.

    BK

    Tuesday, June 17, 2014 4:54 PM
  • Hi,

    Whether the original issue about ID was resolved?

    If no, what is the relationship between ID and FriendlyName/InnerText of the Pane control?

    Are you worrying whether the pane control still can be found on another system because of the dynamic FriendlyName/InnerText property?
     You can try to locate the control without FriendlyName/InnerText property as searchproperties to check the result.

    In order to make the control be found better, we recommend you to specify the value for Id property of the control.

    Thanks,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, June 18, 2014 2:16 AM