繁体   English   中英

Python Selenium:find_element_by_link_text 不起作用

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM