WPF RadGridView find cell by condition

4 posts, 0 answers
  1. Franz
    Franz avatar
    2 posts
    Member since:
    Sep 2012

    Posted 24 Jan Link to this post

    Hello,
    I am using a RadGridView in my WPF application. The RadGridView is filled dynamically, so there might be a different amount of rows every time the test runs. The columns can be reordered.
    The test needs to check a specific cell that is identified by its column header and a value in another cell of that row.

    Example RadGridView data:
    Name        | City        | Workload in hours
    -------------------------------------------
    Foo Bar        | LA        | 45
    John Doe    | NY        | 20

    Now I would like to check the values for "Workload in hours" with a data driven test.
    Example data source for the data driven test:

    Name        | Workload in hours
    -------------------------------
    John Doe    | 20        

    I can't say for sure in what row "John Doe" is since there might be more or less rows in the table. I also can't say if the column is always the third because it might be in another order.
    But I do know that I need:

    "cell
    in COLUMN 'Workdload in hours'
    in ROW where COLUMN 'Name' is <data driven value 'John Doe'>"

    I would like to check if the value inside of that cell matches the data source or do further testing with the row or cell (for example: right click on that cell to edit the person's data in another view).
    Since I use both Telerik control and Telerik Test Studio there should be a way to achieve this without the need to code every step in the RadGridView.

    For the solution it would be okay if I...
    ...add a function to the grid (in the WPF solution) that is called by Telerik Test Studio to get the needed cell for further testing.
    ...create a "Test As Step" that returns the cell AND that can be reused for different tests.
    ...use a test step element that takes parameters (data driven) and returns a cell.

    It would NOT be okay to write a new "Coded Step" for every interaction with a RadGridView because there are lots of RadGridViews.
  2. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    942 posts

    Posted 29 Jan Link to this post

    Hi Franz,

    Thank you for the detailed description of the scenario you have. 

    Please find a sample code article which performs quite similar scenario to the one described. I hope it will be helpful to you! 

    Regards,
    Elena Tsvetkova
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
  3. Franz
    Franz avatar
    2 posts
    Member since:
    Sep 2012

    Posted 30 Jan Link to this post

    Hi Elena,

    In that case I would have to write a new coded step every time I use a RadGridView. Since there are lots of grids in use in the programm, is there any possibility to avoid that?

    As I mentioned: "It would NOT be okay to write a new "Coded Step" for every interaction
    with a RadGridView because there are lots of RadGridViews."

  4. Elena Tsvetkova
    Admin
    Elena Tsvetkova avatar
    942 posts

    Posted 01 Feb Link to this post

    Hi Franz,

    Thank you for the feedback shared. 

    Though the coded approach is meant to handle the scenario when you need to identify a row by any cell content but interact with another cell on that row. It is not a straightforward scenario and this is why it should be handled that way. 

    But you could data drive it or any other iterating actions. Here is an overview how tests could be bound to different types of data sources. Once there is a data source you could also bind input and verifications in code or use the data to data drive an element's find expression - either using the UI or in code as well

    If you would need to interact with the same cell you locate on page you could use the element's find expression - edit it to rely on text content and data drive it to perform the same action multiple iterations. 

    I hope the above information will be helpful to you as well! 

    Regards,
    Elena Tsvetkova
    Progress Telerik
     
    The New Release of Telerik Test Studio Is Here! Download, install,
    and send us your feedback!
Back to Top