Forum Discussion

Taegost's avatar
Taegost
New Contributor
15 years ago

Web Application - Test sorting by column

I am relatively new to using TestComplete and am using it to create automated testing for what will be a rather large web-based application.

In our app, we have quite a few screens with tables, and most of the tables have sortable column headers.  Is there an easy way to make a portable test so that after the header is "clicked", it then checks that the entire table is sorted appropriately?

There are several "gotches" to this:



1) The table contents are dynamic and can change from one run to the next

2) The application will eventually be connected to different databases, with completely different data sets (Only one at a time though)

3) The columns run the gamut from String, Numeric, Date, and single Character

4) The tables will have different numbers of columns and rows



What I'm looking for is something (probably a script) that I can insert in the appropriate place to test the sorting, and something portable so as the application expands I don't have to do any recoding to make it work.

I'm not quite sure where to begin with what I need.

1 Reply

  • Hi Michael,

    You need to create a routine that would perform the following operations:

      1. Retrieve the contents of a column to be sorted into an array.

      2. Sort the array. For instance, do this with JScript's array.sort() method or develop your own sorting algorithm.

      3. Sort the needed column: simulate a click upon the column's header, or if the grid control exposes its members call the respective sorting method.

      4. Compare the contents of the column cells against the array elements.



    The implementation details of this general algorithm would depend on the particular grid control used in your application.



    Good luck.