繁体   English   中英

无法使用相对 xpath 找到元素

[英]Unable to find element using relative xpath

我目前正在尝试使用 xpath 为我的 selenium 项目定位元素,为什么当我尝试运行 selenium 时,它无法使用相对路径定位元素,即使它是 DOM 独有的? 我的目标是使用 div 标签的 title 属性来定位元素,因为 div 标签是非常动态的。

绝对路径

/html[1]/body[1]/div[2]/div[8]/div[1]/div[3]/div[5]

唯一的相对路径

//*//div[@title='This is the title ']

你有没有试过使用

//*[@title='This is the title ']

代替

//*//div[@title='This is the title ']

确实, //*直接在所有子节点中定位元素。

暂无
暂无

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

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