[英]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. 我正在使用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. 我们正在使用编码的UI自动化工具,该工具期望所有HTML控件都应该是唯一的。
For Example : 例如 :
Lets have Grid Table consist of Employee records. 让Grid Table由Employee记录组成。
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. Automation Tester编写了一个测试用例,期望前1-10个记录具有唯一的ID(Emp1-to-Emp10),并且不会更改。
But when Tester sorting the Grid then whole structure of Grid is being changed. 但是,当Tester对Grid进行排序时,将更改Grid的整个结构。 First 10 records will have - Emp11,Emp1,Emp4,Emp5,Emp37,Emp42,Emp67,Emp89,Emp12,Emp10. 前10个记录将具有-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?. 那么,如何通过Angular JS + Coded UI的组合来保持动态记录唯一ID的一致性?
Thanks Gokul 谢谢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. 不要按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. 我所知道的所有测试框架都允许您通过css选择器进行选择,而选择器可以进行比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. 例如,您可以按员工ID查找一行,而无论表格按什么顺序查找它。
From the developer's point of view: 从开发人员的角度来看:
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. 除非您使用一个非常不寻常的框架或受奇怪规则约束,否则我建议修改自动测试而不是代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.