在Workfusion中,我迭代了由xpath找到的HTML页面中的所有元素:
//*以(@id,"FormView1_hidRevElement")开头
当${i} =1时,我得到了所期望的,而不是当${i} >1时。
在HTML页面中,我有如下元素:
id="FormView1_hidRevElement12636“ id="FormView1_hidRevElement12637“ id="FormView1_hidRevElement12642“
等,
抛出错误:..。
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: //*[starts-with(@id,"FormView1_hidRevElement")][2]..。
怎么啦?
发布于 2019-01-22 18:04:52
您创建的XPath是错误的,因为
//*以(@id,"FormView1_hidRevElement")开头
将返回以下id的匹配计数为3
id="FormView1_hidRevElement12636“ id="FormView1_hidRevElement12637“ id="FormView1_hidRevElement12642“
并且每个id匹配等于1,那么显然>1条件将抛出一个错误,因为它不存在。
试试这个XPath:
(//*以(@id,“FormView1_hidRevElement”)开头)${i}
https://stackoverflow.com/questions/54309664
复制相似问题