This is a migrated thread and some comments may be shown as answers.

WPF RadGridView find cell by condition

3 Answers 174 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Franz
Top achievements
Rank 1
Franz asked on 24 Jan 2018, 10:32 AM
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.

3 Answers, 1 is accepted

Sort by
0
Elena
Telerik team
answered on 29 Jan 2018, 08:14 AM
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!
0
Franz
Top achievements
Rank 1
answered on 30 Jan 2018, 08:13 AM

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."

0
Elena
Telerik team
answered on 01 Feb 2018, 01:59 PM
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!
Tags
General Discussions
Asked by
Franz
Top achievements
Rank 1
Answers by
Elena
Telerik team
Franz
Top achievements
Rank 1
Share this question
or