Forum Discussion

prachik's avatar
prachik
Occasional Contributor
14 years ago

How to retrive data from WPF datagrid through TestComplete



 Hi,

 I am working on WPF application.  TestComplete is identifying the rows in the grid with the help of acct Ordinal identifier.There are multiple columns in one row.In one of my test scenarion , If that Ordinal Identifier is identified, I want value of perticular cell, which is only been identified with the properties  ordinal identifier,Text and class. Text is the only property which identifies the cell unique, however I can't provide text as I need this for verification.

Is there a way by which we can map this datagrid into Table ,so that we can identify each cell uniquely.or any property?



Please provide a solution
  • Techtravel's avatar
    Techtravel
    Occasional Contributor
    This sounds almost exactly like an issue I am currently having within a few WPF sections within our application. Columns seem to identify but is unable to map/record into proper rows/cells.



    This is an issue I had addressed a few months ago and was told something was being worked on to correct the issue within 8.5, we have since been using 8.2 hoping there would be a new update or a hotfix, however I still see the latest update is from May.



    Could we have a resolution for this issue and maybe some sort of timeframe for the next release or at least a hotfix for 8.5?
  • AlexeyK's avatar
    AlexeyK
    SmartBear Alumni (Retired)

    Prachi, Jason,


    What WPF grid are you using? If this grid is supported by TestComplete, you can use the wValue property to retrieve cell values.


    If TestComplete does not provide special support for your grid, try retrieving cell values with native methods and properties of the grid object. What methods and properties to use depends on your grid. You can explore the grid documentation or ask the developers. For instance, Xceed.Wpf.DataGrid contains the Items property that provides program interface for the grid rows. To obtain a cell value, you can use code like WPFObject("grid").Items.Item(0).Item(2). Here Item(0) corresponds to the first row of the grid and Item(2) corresponds to the third column in the row.


    It is not recommended that you work with grid rows by using objects from the Object Tree. The tree displays objects that TestComplete recognizes in the tested application. Typically, these objects only correspond to visible rows (that is, this is the object structure in the tested application). Also, these objects change if you scroll the grid contents. This makes it difficult to work with the grid. The approach involving native methods and properties doesn't have such drawbacks.

  • smitad's avatar
    smitad
    Occasional Contributor

    Hi Alex,


    Im working on the same problem that Prachi is. I have a WPF Grid with classname "Infragistics.Windows.DataPresenter.RecordListControl" and the Rows are identified as DataRecordPresenter. The cell value headers are filters and they also appear as a row in the Grid. So it is difficult to find a value for a specific header.The Row indexes also change . Let me know if you can suggest how to identify these headers and columns uniquely and get a value of it in a variable.



    Regards

    Smita

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)


    This is an issue I had addressed a few months ago and was told something was being worked on to correct the issue within 8.5, we have since been using 8.2 hoping there would be a new update or a hotfix, however I still see the latest update is from May.



    Could we have a resolution for this issue and maybe some sort of timeframe for the next release or at least a hotfix for 8.5?



    Jason, let me know the issue number. I'll look up its status.
  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)
    Hi Smita,



    Could you post here a screenshot of what your grid looks like and mark the values you wish to capture?

    Also, let me know the version number of the grid control and your TestComplete version.
    • gvkr1985's avatar
      gvkr1985
      Occasional Contributor

      I am also working on WPF Application, and unable to get the row index for one of the Cell. 

      I am able to identify the cell by using below code.

       

      Set Obj1 = tableSearchResults.FindChild ("Text",Excel_Open.Value(i_Index_OrganizationName),2)
      If Obj1.Exists then
      Log.Message Obj1.WPFControlIndex
      Else
      Log.Message "Organization : "& Excel_Open.Value(i_Index_OrganizationName) &" is not found"
      End If

       

      It is giving the column level...but I need the DataGrid Row value so that i can click on the Update button for that perticular row..

       

      Please help...

       

       

      • TanyaYatskovska's avatar
        TanyaYatskovska
        SmartBear Alumni (Retired)

        Hi Venkat,

         

        Try exploring your grid in TestComplete’s Object Browser to identify what properties/methods you can use. To make sure that you see all available properties, switch to the Advanced View mode and allow showing hidden members. Please refer to the "Basic and Advanced View Modes" ( http://smartbear.com/viewarticle/55599/ ) help topic for details.

         

        If this doesn’t help, let us know what control you are testing (its name and vendor).