【问题标题】:Web page in Chrome does not open with selenium in PythonChrome 中的网页无法在 Python 中使用 selenium 打开
【发布时间】:2017-12-16 07:13:22
【问题描述】:

以下代码会打开一个 chrome 标签,但不会打开 google 链接。

错误:“您正在使用不受支持的命令行标志”

from selenium import webdriver
driver=webdriver.Chrome("E:\\Chrome Driver\\chromedriver.exe")
driver.get('https://www.google.com')
driver.implicitly_wait(20)
driver.quit()

【问题讨论】:

  • 路径应该是 r 前缀,如 r"E:\\Chrome Driver\\chromedriver.exe" 而不是 "E:\\Chrome Driver\\chromedriver.exe" 。最后的声明应该像driver=webdriver.Chrome(r"E:\\Chrome Driver\\chromedriver.exe")
  • 反斜杠可能是问题所在。你可以试试webdriver.Chrome("E:/Chrome Driver/chromedriver.exe")
  • 驱动和你的文件放在同一个目录下,不需要定义驱动路径。
  • 谢谢。我试图将其转换为原始字符串,但即使出现同样的错误。此外,它还要求禁用开发者扩展
  • 谢谢。我试图将其转换为原始字符串,但即使出现同样的错误。此外,它还要求禁用开发者扩展

标签: python python-3.x


【解决方案1】:

【讨论】:

  • 是的,安装 chromedriver 2.34 后它工作了!谢谢。
猜你喜欢
  • 2017-08-02
  • 2021-09-25
  • 2018-08-25
  • 2020-08-12
  • 2020-01-26
  • 2020-11-25
  • 1970-01-01
  • 2020-07-29
  • 2017-12-27
相关资源
最近更新 更多