简体   繁体   English

定位具有动态属性的元素

[英]Locating elements with dynamic attributes

I ve been running some tests using selenium java and after every run element attributes in HTML change.我一直在使用 selenium java 运行一些测试,并且每次运行 HTML 中的元素属性都会发生变化。 I am testing a full web app from intellij ide using selenium 4.1.2 and mvn 3.8.5 while the web app .NET and Angular 13. Any idea what is the cause of this problem ?我正在使用 selenium 4.1.2 和 mvn 3.8.5 测试来自 intellij ide 的完整网络应用程序,而网络应用程序 .NET 和 Angular 13。知道这个问题的原因是什么吗?

您可以通过两个 mwthods 找到它 1) 如果属性值的一部分是静态的,而剩余的值是动态的,比如说 id=ABC123 并且 123 是动态的,而 ABC 是静态的,请尝试使用带有 contains (@id,'ABC' 的 xpath ) 或尝试定位前一个静态元素并使用以下方法遍历并定位该元素

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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