Locked Find the control in VS CUIT based on row and column

  • Wednesday, September 12, 2012 2:17 PM
     
     

    I am developing an automated testing application by using VS Coded UI Test 2010. This application is used to test a web applicaton which is written in HTML, XML and ASP language. How can I find the controls which values are 6 and 7 based on "Student A", "Subject A", "Subject B" as the picture below? I want to do this because in the test case, it is said that I need to get or set the mark of Student A in Subject A and B. 

    Regards,

    Tu.

All Replies

  • Thursday, September 13, 2012 6:21 AM
    Moderator
     
     Answered

    Hello Tu,

    Thank you for posting in the MSDN forum.

    In order to find controls, you can record some actions on UI Control using Coded UI Test Builder and drag the crosshair onto the UI Control to add assertions. In test execution phase, Coded UI test captures some set of properties on the control and name them as “Search Properties” and “Filter Properties” in order to find a control.

    For detailed information, you can refer to Balagans’ blog:How does “Coded UI test” finds a control ??

    In addition, you can use DrawHighlight() method to make a control highlight.

    About DrawHighlight() method, you can see:FAQ: Some Minutiae on DrawHighlight()

    Best regards,


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

  • Friday, September 14, 2012 12:02 AM
     
     

    Hi Amanda,

    Thanks for your answer.

    In my project, some of the controls are not always in the browser so I have to write the code to find them. Depends on the test cases, for example, with the first test case, a particular control is not in the browser but with the second test case, that control will appear in the browser and the id property or name property of that control will be generated automatically so we can not know the id and name of that control.

    In addition, in the future, maybe the developers will move the control, change id or name, or add some columns or rows. So how can I find them?

    Best regards,

    Tu.

  • Friday, September 14, 2012 7:15 AM
    Moderator
     
     

    Hello Tu,

    When the controls appear in the second test case, you can record them at that time to find controls.

    If you move the control, it should not affect Coded UI Test.

    Because the ID and Name property is generated automatically, in order to find the control, you don’t use SearchProperties and FilterProperties for the two properties and look for controls through other properties.

    In addition, if you can know the property value in advance and specify them, you can use SearchProperties and FilterProperties to look for the matching control.

    I hope it can help you.

    Best regards,


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

  • Friday, September 14, 2012 7:29 AM
     
     

    Hi Amanda,

    Thanks for your answer.

    Because I am going to develop an automated testing application for BAs and testers to use it. Therefore, I can not record the test again to find the controls.

    When running, the web application will create a XML file to store the controls, so can CUIT can read that XML file? If yes, I can find the controls based on that XML file.

    Best regards,

    Tu.

  • Friday, September 14, 2012 8:45 AM
    Moderator
     
     

    Hello Tu,

    We can create a Data-Driven Coded UI test with an xml file as a data base. Some data used in Coded UI test can be retrieved from the xml file.

    For detailed information, you can refer to this article about How to: Create a Data-Driven Coded UI Test

    I hope it can help you.

    Best reagrds,


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

  • Friday, September 14, 2012 12:41 PM
     
     

    Hi Amanda,

    Thanks for your answer.

    I knew about the datasource of CUIT. But what I mean is the XML which is generated automatically by the web application that I want to test, not the XML file which is the datasource of CUIT. By reading that XML, I can know some information about the controls in the web browser. But I don't know that CUIT can do that or not?

    Best regards.

  • Monday, September 17, 2012 8:43 AM
    Moderator
     
     Answered

    Hello Tu,

    Coded UI Test can read an xml file, but it should be done programmatically.

    About reading xml file by using Visual C#, you can refer to the following article:

    http://support.microsoft.com/kb/307548

    I hope it can help you.

    Best regards,


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