defecationwarning:find_element_by_*命令已弃用

发布于 2025-01-27 19:58:14 字数 288 浏览 2 评论 0原文

我正在尝试恢复我的旧脚本,该脚本一直奏效。自从我切换到Python 3以来,我遇到了很多问题。启动脚本后出现了此错误:

DeprecationWarning: find_element_by_* commands are deprecated

这是提出问题的代码行:

driver.find_element_by_xpath("//*[@title='Consent all cookies']").click()

有人可以帮助我吗?

I'm trying to recover an old script of mine, which has always worked. Since I switched to Python 3 though, I'm having a lot of problems. This error came up after launching the script:

DeprecationWarning: find_element_by_* commands are deprecated

This is the line of the code which presents the problem:

driver.find_element_by_xpath("//*[@title='Consent all cookies']").click()

Can anyone help me?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谁对谁错谁最难过 2025-02-03 19:58:14

您需要添加以下导入:

from selenium.webdriver.common.by import By

然后替换以下:

driver.find_element_by_xpath("//*[@title='Consent all cookies']").click()

以下:

driver.find_element(By.XPATH, "//*[@title='Consent all cookies']").click()

You need to add the following import:

from selenium.webdriver.common.by import By

Then replace this:

driver.find_element_by_xpath("//*[@title='Consent all cookies']").click()

with this:

driver.find_element(By.XPATH, "//*[@title='Consent all cookies']").click()
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文