Forum Discussion

azakharov's avatar
azakharov
Contributor
12 years ago

Dynamic Tables

Our application has a lot of dynamic tables as in attached file. The order of items in tables can change as records added, modified, removed. What is the best strategy for locating elements in this situation?

For example I need to find a row in a table that contains some text inside and then click on delete button few rows to the right. It can not be just let's say 3rd button of the table (as 3rd button may be not for the same record on next run) it has to be row with specific text in it.



With Selenium it would be something like this:

css=td:contains("BRAND, NEWTWO")+td+td+td+td+td+td+td>img[title='Delete this person']



Is it possible to create this logic through the TestComplete UI? If not what is the easiest code solution?

I have some experience with Python but not with VBScript, JScript, DelphiScript, C++Script or C#Script.



Thanks again.



Best regards,

Andrey Zakharov.

1 Reply


  • Hi Andrey,


     


    It's possible to use XPath expressions in TestComplete. For example, the code below gets an INPUT web element whose type attribute is equal to "button" and click it. Refer to the "Finding Web Objects Using XPath Expressions" article to learn more about this.


     




    //JScript


        var page = // obtian the tested page


        var obj = page.FindChildByXPath("//INPUT[@type='button']", false);


     


        // Check the result 


        if (obj != null)


        {


          // If the element was found, click it


          obj.Click(); 


        }