简体   繁体   English

如何在Selenium中记录用于动态ID生成的脚本

[英]How to record the script for dynamic ID generation in Selenium

I am working on Selenium IDE. 我正在使用Selenium IDE。 Currently I am facing problem related to dynamic id. 目前,我面临与动态ID相关的问题。 I have recorded one script, but when I run it again it fails because id changes every time. 我已经记录了一个脚本,但是当我再次运行它时,它会失败,因为id每次都会更改。

Is there any way to get rid of this?? 有什么办法摆脱这个? Waiting for reply 等待回复

thanks in advance 提前致谢

Generally - try switching from ID search to XPath. 通常-尝试从ID搜索切换到XPath。 See examples here: http://zvon.org/xxl/XPathTutorial/Output/example1.html 在此处查看示例:http: //zvon.org/xxl/XPathTutorial/Output/example1.html

But in that case you have to know that your element is always first SPAN of second table (just example) 但是在这种情况下,您必须知道您的元素始终是第二个表的第一个SPAN(仅作为示例)

You should use other type of locators (for example xPath - as Pavel Janicek wrote). 您应该使用其他类型的定位器(例如xPath-如Pavel Janicek所写)。
Here is an article about Selenium locators http://www.qaautomation.net/?p=188 这是有关硒定位器的文章http://www.qaautomation.net/?p=188
Read it and choose the best way for you. 阅读并选择最适合您的方法。

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

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