【问题标题】:Using webdriver to run in Chrome with Python使用 webdriver 在 Chrome 中运行 Python
【发布时间】:2015-12-09 15:45:21
【问题描述】:

我一直在 webdriver 中使用 Firefox。我想尝试使用 Chrome。我已经下载了 chromedriver 并将其包含在 Path 变量中。但是,此代码返回错误:

>>> webdriver.Chrome()

selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

我也尝试过包含路径:

>>> webdriver.Chrome('C:\Python34\chromedriver_win32.zip')

OSError: [WinError 193] %1 is not a valid Win32 application

这里有什么问题?如果我做错了什么或者我的问题似乎很难解决,我很抱歉。任何帮助将不胜感激。我也搜索了整个互联网,但我还没有找到任何东西。

说真的,没有人能解决这个问题吗?

【问题讨论】:

  • 为简单起见,请将chromedriver.exe 包含在与您的脚本相同的文件夹中。
  • 您必须解压 zip 文件夹才能获得必要的chromedriver.exe
  • @malik 似乎有点用。得到一个不同的错误:
  • @ma selenium.common.exceptions.WebDriverException: Message: 'chromedriver_win32' executable may have wrong permissions. Please see https://sites.google.com/a/chromium.org/chromedriver/home

标签: python google-chrome selenium


【解决方案1】:

事实证明,我必须解压缩文件夹,而不是输入文件夹的路径作为参数,您还必须在路径中提供 .exe 文件。也许这是一个间歇性的事情,或者只是在我发布问题时不起作用。

【讨论】:

    猜你喜欢
    • 2012-01-05
    • 2019-05-08
    • 1970-01-01
    • 2017-08-12
    • 2013-06-09
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 2017-02-28
    相关资源
    最近更新 更多