简体   繁体   中英

How developers can assign Unique Id for HTML Controls in Grid which can used by Automation Test tool like Code UI?

I am using Angular JS - ng-table. Which generates grid structure with Sorting, filtering, pagination features.

We are using Coded UI automation tools which expects all HTML controls should be Unique.

For Example :

Lets have Grid Table consist of Employee records.

Automation Tester wrote a test cases expecting the first 1-10 records are having unique Id (Emp1-to-Emp10) which is NOT going to be changed.

But when Tester sorting the Grid then whole structure of Grid is being changed. First 10 records will have - Emp11,Emp1,Emp4,Emp5,Emp37,Emp42,Emp67,Emp89,Emp12,Emp10.

when the Tester re test the test case it FAILs .

So, how to maintain the consistency for dynamic records unique ids with the combination of Angular JS + Coded UI?.

Thanks Gokul

I would say that what is happening is expected sorting behaviour..

Some ways that you could solve your problem. From the tester's point of view:

  • Tests should restore the page to the initial state before ending. For example if the test sorts a table, it should 'un-sort' the table before it finishes. This leaves the data in an expected state so that the test can be repeated

  • Don't select things by id. All the test frameworks I know of allow you to select things by css selectors, which can do much more powerful selections than by id. Eg you could look up a row by the employee Id and it would find it regardless of what order the table is in.

From the developer's point of view:

  • I presume the rows are items in an array. You can assign a unique id as a property to each item in the array and use it in the template markup. The unique id would not be affected by any sorting.

Unless you are using a very unusual framework or constrained by strange rules, I would suggest that the automated tests are amended rather than the code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM