Tokci
Tokci

Reputation: 1280

How to click on a link in a specific row of dynamically loaded table

I have a table similar to below in a WPF application. We are using Silk Test 17.5 using VB.NET.

enter image description here

Table is dynamically loaded based on latest data. I need to click on 'Default' ( Link) for specific row.

e.g. I need to click on 'Default' link for Trump1 , Trump2 row.

How should I do it? All locators of default links are same and I cannot differentiate between them. Is there any I can append First Name locator to Default to figure out which locator to click?

Tokci

Upvotes: 0

Views: 285

Answers (2)

tehlexx
tehlexx

Reputation: 2859

Assuming the table has a hierarchical structure similar to HTML, you should be able to do the following:

  1. Locate a cell in the row you are looking for that is easy to find, e.g. //WPFDataGridCell[@text='Obama'].
  2. From that cell, move up the hierarchy one step using ...
  3. Now you're in the correct WPFDataGridRow, search down again for the row's "Default" link with //WPFHyperLink[@caption='Default'].

Putting it all together, you'll get a locator like //WPFDataGridCell[@text='Obama']/..//WPFHyperLink[@caption='Default'].

Of course this is only an example based on the information you provided, so if you try it, make sure to pick the attributes with Silk Test's locator spy to make sure you get the correct values.

Upvotes: 1

Bela Tamas Jozsa
Bela Tamas Jozsa

Reputation: 714

SilkTest has a framework for supporting such custom controls and a nice tutorial here Theoretically you would have to:

  1. List all the methods on the control
  2. From the previous listing (or by talking with the developers) look up the method to access the rows inside the control
  3. Filter your rows and get the one which is interesting for you
  4. From the row you can get the cell by following the same pattern(find out the method which gives acces to it, get it, filter)
  5. Click on the Link

Of course as the tutorial tells you, if you do not want to always do these iterations you should create some higher level utilities where you can just get the Cell at once. Example: GetGridViewRowCell(gridView, cellRow, cellColumn) where cellRows can be a more sophisticated filter object where you describe which cell must have which value in order to identify the proper row

Upvotes: 2

Related Questions