简体   繁体   English

硒RC(动态ID生成)

[英]Selenium RC ( Dynamic Id Generation)

我在Eclipse和JUnit中使用Selenium RC,如何捕获动态ID,请尽快回答

To use work against dynamic IDs you need to either use CSS selectors or XPath. 要针对动态ID使用工作,您需要使用CSS选择器或XPath。

For xpath you would have xpath=//input[@contains(@id,'partOfId')] to find an input where you know part of the ID or for css it would be css=input[id^='partOfId'] 对于xpath,您可以使用xpath=//input[@contains(@id,'partOfId')]来查找您知道部分ID的输入,或者对于CSS,它应该是css=input[id^='partOfId']

To make them static isn't always possible for particular project(framework used). 对于特定项目(使用框架)而言,使其始终不静态是不可能的。

You may deal with developers, that they provide rules for ID prefixes or postfixes. 您可以与开发人员打交道,他们为ID前缀或后缀提供规则。

And then check correspondingly with XPATH selectors and regexp. 然后使用XPATH选择器和regexp进行相应检查。

You can use static name instead. 您可以改用静态名称。 Or your own custom locator 或您自己的自定义定位器

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

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