栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

selenium.common.exceptions.WebDriverException:消息:无头Chrome浏览器的“chromedriver”可执行文件需要出现PATH错误

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

selenium.common.exceptions.WebDriverException:消息:无头Chrome浏览器的“chromedriver”可执行文件需要出现PATH错误

如果我们分析日志,似乎主要问题在于in

start os.path.basename(self.path)
和随后的错误消息
selenium.common.exceptions.WebDriverException: Message: 'chromedriver'executable needs to be in PATH

因此,从错误中很明显,Python客户端无法找到

chromedriver
二进制文件。

您必须在这里注意以下几点:

  1. chrome_options.binary_location
    :参数配置
    chrome.exe
    不是
    chromedriver.exe
  2. os.path.abspath("chromedriver")
    将选择的文件路径,
    chromedriver
    但不会
    chromedriver.exe
    在末尾追加。
  3. 这里是我的示例代码
    Windows 8
    系统开始
    Chrome
    Headless Mode
        from selenium import webdriver      from selenium.webdriver.chrome.options import Options     chrome_options = Options()      chrome_options.add_argument("--headless")      driver = webdriver.Chrome(chrome_options=chrome_options, executable_path=r'C:UtilityBrowserDriverschromedriver.exe')      driver.get("http://www.duo.com")     print("Chrome Browser Initialized in Headless Mode")    driver.quit()    print("Driver Exited")


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/447806.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号