2017-10-18 104 views
-1

为什么我不能捕捉使用
driver.find_element_by_link_text(“交易数据”)这个元素点击硒webdriverusing蟒蛇悬停菜单上的项目

Sample

+0

前请在你的问题的HTML片段而不是HTML的图像。 – bated

+0

可能的问题是,此处A标签内不仅仅有文本。很多时候,引入额外的空白到完全匹配不起作用的地方。有几种解决方法是切换到'.find_element_by_partial_link_text()'。如果仍然存在与其他元素的碰撞,则必须找到另一种可用的定位器。 – JeffC

回答

0

你可以尝试使用XPath代替,因为CSESectorSummery似乎是该链接的一个独特部分。试试这个:

driver.find_element_by_xpath("//a[@ui-sref='CSESectorSummery']"); 

把一个@在UI的SREF

+0

selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法找到元素:{“method”:“xpath”,“selector”:“// a [ui-sref ='CSESectorSummery']”} – Chamisxs

+0
+0

我的道歉,把@放在ui-sref的前面。 “// a [@ ui-sref ='CSESectorSummery']” – JOberloh