Search code examples
seleniumautomated-testssilktest

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


Solution

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