[英]Unable to locate element inside a table using xpath with selenium
[英]Unable to locate a link using xpath
我无法使用xpath在页面上找到链接。 当我使用“检查元素”命令时,对象的页面源如下:
<a id="TreeView1_LinkButtonMore" href="javascript:__doPostBack('TreeView1$LinkButtonMore','')">
See more
</a>
我的硒代码如下:
driver.FindElement(By.XPath("//*[@id='TreeView1_LinkButtonMore')")).Click();
我得到的错误如下:
给定的选择器//*[@id='TreeView1_LinkButtonMore')
无效或未生成WebElement。 发生以下错误:
InvalidSelectorError: Unable to locate an element with the xpath expression //*[@id='TreeView1_LinkButtonMore')
提前致谢
尝试这个:
driver.FindElement(By.XPath("//*[@id='TreeView1_LinkButtonMore']")).Click();
但是,可能需要指出的是,这完全相同的事情的捷径是:
driver.FindElement(By.Id("TreeView1_LinkButtonMore")).Click();
您的xpath中有语法错误。 结束符应该是方括号而不是曲线括号语法:// tag-name [@ attribute ='value']
尝试这个:
driver.FindElement(By.XPath(“ // a [@ id ='TreeView1_LinkButtonMore']”))。Click();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.