Python Selenium Chrome Web驱动程序

费尔南多·加里波第:

我开始自动化无聊的东西书,并且尝试通过python打开chrome网络浏览器。我已经安装了硒和

我试图运行此文件:

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

browser = webdriver.Chrome()
browser.get('https://automatetheboringstuff.com')

但是正因为如此,我得到这个错误:

Traceback (most recent call last):   File "C:\Program Files
   (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py",
 line 74, in start
     stdout=self.log_file, stderr=self.log_file)   File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 707, in __init__
     restore_signals, start_new_session)   File "C:\Program Files (x86)\Python36-32\lib\subprocess.py", line 990, in _execute_child
     startupinfo) FileNotFoundError: [WinError 2] The system cannot find the file specified

在处理上述异常期间,发生了另一个异常:

Traceback (most recent call last):   File "C:/Program Files
(x86)/Python36-32/test.py", line 5, in <module>
    browser = webdriver.Chrome()   File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py",
line 62, in __init__
   self.service.start()   File "C:\Program Files (x86)\Python36-32\lib\site-packages\selenium\webdriver\common\service.py",
line 81, in start
   os.path.basename(self.path), self.start_error_message) selenium.common.exceptions.WebDriverException: Message: 'chromedriver'
  executable needs to be in PATH. Please see
https://sites.google.com/a/chromium.org/chromedriver/home
艾哈迈德·塔哈(Ahmad Taha):

您需要指定chromedriver所在的路径

  1. 从此处下载适用于所需平台的chromedriver

  2. 将chromedriver放置在系统路径或代码所在的位置。

  3. 如果不使用系统路径,请链接您的chromedriver.exe(对于非Windows用户,简称为chromedriver):

    browser = webdriver.Chrome(executable_path=r"C:\path\to\chromedriver.exe")
    

    (设置executable_path为chromedriver所在的位置。)

    如果您在系统路径上放置了chromedriver,则可以通过以下操作来实现快捷方式:

    browser = webdriver.Chrome()

  4. 如果您在基于Unix的操作系统上运行,则可能需要在下载chromedriver后更新chromedriver的权限才能使其可执行:

    chmod +x chromedriver

  5. 就这样。如果您仍然遇到问题,可以在此其他StackOverflow文章中找到更多信息:不能对Selenium使用chrome驱动程序

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

检测到带有chrome驱动程序的Python Selenium Web驱动程序

如何在python中的Selenium Chrome Web驱动程序中获取状态代码

Selenium(Python)-等待使用Chrome Web驱动程序完成下载过程

如何隐藏Chrome Web驱动程序图标(Python-Selenium)

Selenium:循环Web驱动程序(Python)

Python Selenium Chrome 驱动程序找不到元素

在 element selenium python chrome 驱动程序中查找元素

如何使用 selenium Web 驱动程序单击元素(Python)

从python selenium web驱动程序中的文本裁剪整数

Selenium Web 驱动程序 | 查找对象 | Python

Selenium Chrome驱动程序74.0.3729.6问题

如何使用 selenium、chrome 驱动程序和 python 关闭新建的选项卡

使用带有Chrome驱动程序的Selenium Python拍摄整个网页的屏幕截图

Python Selenium Chrome 驱动程序在启动浏览器后不输入 url

与Python搭配使用时,Selenium Chrome驱动程序中的常见异常

在python 3中使用Selenium Chrome驱动程序将文本插入文本框

如何将Chrome驱动程序与Selenium一起使用Python登录到Applemusic

Python Selenium chrome驱动程序.send_keys NoneType错误

如何找到使用Selenium Web驱动程序(用于Chrome)从PHP下载的文件的路径和名称?

无法通过 xpath 通过 selenium chrome 驱动程序单击 Web 元素

如何配置Selenium Web驱动程序以在后台启动chrome浏览器

让Selenium Chrome驱动程序启动“真正的” Chrome

使用 Python 的 Selenium 网络驱动程序

Selenium Webdriver和Chrome驱动程序-无法运行Chrome驱动程序

Selenium(C#)Chrome驱动程序:自从Chrome Web驱动程序版本77起,就不再像以前那样管理页面加载

带有 Python 的 Selenium Webdriver - 无法在使用 Selenium Web 驱动程序的 Web 应用程序中提供输入(日期)

如何使用 selenium chrome 驱动程序在 Python 中按名称过滤网络调用条目?

为什么 selenium 找不到 chrome 驱动程序?

Selenium Webdriver不会退出Chrome驱动程序