Selenium Webdriver Xpath 不工作 [英] Selenium Webdriver Xpath not working
本文介绍了Selenium Webdriver Xpath 不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用 selenium webdriver 单击链接文本,但无法正常工作,
Im trying to click a link text using selenium webdriver but is not working,
这是图片
在使用 firebug 的 firefox 上我得到了 xpath
On firefox using firebug I got the xpath
html/body/div[1]/div/div/div[2]/div[2]/div[2]/a
我用过
driver.findElement(By.xpath("html/body/div[1]/div/div/div[2]/div[2]/div[2]/a")).click();
但还是不行,有什么原因吗?
but still doesnt work, any reason to why?
推荐答案
我在你的 html 代码中看到 name 属性,但元素类型是隐藏的.Selenium 不与隐藏元素交互.尝试使用其他路径,如//输入[@id='offerId']/..//a
"
I see name attribute in your html code but the element type is hidden.Selenium doesn't interact with hidden elements.Try using other path like "//input[@id='offerId']/..//a
"
这篇关于Selenium Webdriver Xpath 不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文