只是一个问题,我尝试对表单进行验收测试(填写字段),并在每次刷新时动态生成一个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/