2.) The same thing can also be achieved using the Math.random() (for JS), which returns a value between 0 and 1 (0.8018194703223693), 18 digits long.var almostUnique = Math.random();// You can go ahead and gen only the decimalsalmostUnique = almostUnique.toString().split('.')[1];var email = 'test.e2e' + almostUnique + '@<yourMainDomainHere>' !!! 警告:虽然Math.random()实际上不是 ,但是在200个功能测试用例的数百次回归运行中,我没有机会看到副本.!!! Warning: While Math.random() is not actually unique, in hundreds of regression runs of 200 functional test cases, I didn't have the chance of seeing a duplicate. 3.)(不太优雅|难以指数实现)如果您可以访问网络应用程序后端API ,并可以通过它执行不同的操作在数据库中,您实际上可以编写一些脚本,这些脚本将在 注册 测试用例之后运行,例如 cleanup 套件.3.) (Not so elegant | Harder exponentially harder to implement) If you have access to your web-apps backend API and through it you can execute different actions in the DB, then you can actually write yourself some scripts that will run after your registration test cases, like a cleanup suite.这些脚本必须从数据库中删除以前添加的用户.These scripts will have to remove the previously added user from your database.希望这会有所帮助! 这篇关于Selenium Webdriver-如何避免数据重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 1403页,肝出来的.. 09-06 12:24