繁体   English   中英

selenium.common.exceptions.WebDriverException:消息:未知错误:无法使用 ChromeDriver Chrome Selenium 创建 Chrome 进程错误

[英]selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create a Chrome process error with ChromeDriver Chrome Selenium

我正在尝试使用 webdriver 编写基本的 python-Google Chrome 交互代码,但是在尝试在浏览器上启动链接时,我经常遇到相同的错误。

这是我的代码:

from selenium import webdriver
import os

class Instagrambot:
    def __init__(self, username, password):
        self.username = username
        self.password = password

        self.driver = webdriver.Chrome('./chromedriver.exe')


if __name__ == '__main__':
    ig_bot = Instagrambot('temp_username', 'temp_password')

我在当前目录中有 chromedriver,我正在为我的浏览器 (Chrome 79.0.3945.88) 使用正确版本的 chromedriver (79.0.3945.36)。 我得到的完整错误是:

Traceback (most recent call last):
  File "c:/Users/Arthur/Documents/instabot/bot.py", line 16, in <module>
    ig_bot = Instagrambot('temp_username', 'temp_password')
  File "c:/Users/Arthur/Documents/instabot/bot.py", line 12, in __init__
    self.driver = webdriver.Chrome('./chromedriver.exe')
  File "C:\Users\Arthur\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__desired_capabilities=desired_capabilities)
  File "C:\Users\Arthur\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__self.start_session(capabilities, browser_profile)
  File "C:\Users\Arthur\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session response = self.execute(Command.NEW_SESSION, parameters)
  File "C:\Users\Arthur\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "C:\Users\Arthur\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response 
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create a Chrome process.

我已经尝试过:

将完整的可执行路径写入 chromedriver.exe(与 bot.py 相同的文件夹)

按照此答案中的建议覆盖 Chrome 二进制位置: https : //stackoverflow.com/a/53078276/11206079

如果有人可以帮助我或提供有关如何修复它的任何见解,我将非常高兴!

这个错误信息...

selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create a Chrome process.

...暗示ChromeDriver无法启动/生成新的浏览上下文,Chrome 浏览器会话。

我在您的代码块中没有看到任何此类问题。 但是,有关您正在使用的二进制文件版本和用户类型的测试环境的更多详细信息将有助于我们以更好的方式调试问题。 但是,您很可能以管理员身份执行测试



其他注意事项

确保这件事:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM