![](/img/trans.png)
[英]Click on a link in Selenium: find_element_by_link_text doesn't work
[英]Python Selenium: find_element_by_link_text doesn't work
三年來,我一直在使用 Python 的 Selenium 綁定與 PyCharm CE,並且從未遇到過任何功能問題。
但是現在我在嘗試使用 find_element_by_link_text 時遇到了一個非常奇怪的錯誤
browser.find_element_by_link_text("Administration").click()
錯誤如下:
selenium.common.exceptions.JavascriptException: Message: javascript error: this.each is not a function
其他 find_element_by 函數工作得很好。
將包括selenium
在內的所有軟件包更新到 4.0 后,除了上述內容外,我還收到了以下警告:
UserWarning: find_element_by_* commands are deprecated. Please use find_element() instead
warnings.warn("find_element_by_* commands are deprecated. Please use find_element() instead")
我再次將selenium
降級為 3.141.0,但隨后我再次收到this.each
錯誤而沒有任何警告。
我還嘗試了 selenium.dev 給出的其他不同方法,例如
browser.find_element(By.LINK_TEXT, value="Administration")
但它們似乎也不起作用。
發生了什么變化? 我必須改變什么? 為什么所有其他類似的 find_element 函數都像 id/xpath/visible_text/etc 一樣。 工作? 我束手無策,我不想重寫我所有的 find_element_by_link_text 調用。 :(
function 終於可以與 Chrome 83 Beta 和 Chromedriver 83 一起使用,看起來問題是由舊版 Chromedriver 引起的,錯誤地調用了prototype.js。
版本 83 的補丁說明:
“更新了 Chromedriver 以與prototype.js 一起正常工作。”
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.