xpath - 测试Codeception/webdriver和动态表单ID

标签 xpath webdriver codeception dynamicform

只是一个问题,我尝试对表单进行验收测试(填写字段),并在每次刷新时动态生成一个ID。我正在寻找一种方法来获取表单ID,或使用部分xpath,但我没有找到它。

<input type="text"     name="searchform_fb1831c63342af1bc6b8744181e2cc5b[simpleCriteria][NAME]"     id="searchform_fb1831c63342af1bc6b8744181e2cc5b-simpleCriteria-NAME" value=""     size="40" class="manage_ul_error text-input">


任何建议都会受到欢迎,谢谢。

最佳答案

一种选择是检查id属性是否包含searchform_

//input[@type='text' and contains(@id, 'searchform_')]


或者,从以下开始:

//input[@type='text' and starts-with(@id, 'searchform_')]


您还可以另外检查class

//input[@type='text' and @class='manage_ul_error text-input' and starts-with(@id, 'searchform_')]

关于xpath - 测试Codeception/webdriver和动态表单ID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24366436/

相关文章:

linux - RHEL + 代码接收 : invalid mit-magic-cookie-1 keyerror cannot open display :2. 0

selenium - 我如何停止断言失败时关闭浏览器窗口的代码接收/ Selenium ?

python - ElementClickInterceptedException : Message: element click intercepted: Element <label> is not clickable with Selenium and Python

javascript - 如何在 JavaScript 中使用 XPath 从命名空间的 OOXML 中进行选择?

selenium - Selenium 的两种不同语法结构

codeception - 将本地设置导入 codeception.yml

xml - 如何更新System.Xml.XmlDocument中的节点值?

javascript - 抓取隐藏在 javascript 对象后面(?)的文本

javascript - 使用 xpath 获取并打印出元素

java - 没有 xpath 选项的标签复选框选择