2017-10-18 99 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