selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed with ChromeDriver and Selenium in Python

前端 未结 1 1959
悲哀的现实
悲哀的现实 2020-12-02 02:28

This is my code script:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument(\"user-data-dir=C:\\\\Users         


        
相关标签:
1条回答
  • 2020-12-02 03:33

    Thumb rule

    A common cause for Chrome to crash during startup is running Chrome as root user (administrator) on Linux. While it is possible to work around this issue by passing --no-sandbox flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged. You need to configure your environment to run Chrome as a regular user instead.


    As per your code trials seems you are trying to access a Chrome Profile so you can use the following solution:

    • Code Block:

      from selenium import webdriver
      from selenium.webdriver.chrome.options import Options
      
      options = Options()
      options.add_argument("user-data-dir=C:\\path\\to\\your\\profile\\Google\\Chrome\\User Data\\Profile 2")
      driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', chrome_options=options)
      driver.get("https://www.google.co.in")
      
    • Here you can find a detailed discussion in How to open a Chrome Profile through Python

    0 讨论(0)
提交回复
热议问题