selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create Chrome process with ChromeDriver Chrome with Selenium Python

后端 未结 2 2054
猫巷女王i
猫巷女王i 2020-12-11 13:09

I am trying to click a button using selenium so I made it find the element with the xpath since i couldn\'t find the id . EDIT: I didn\'t think the rest of the code had anyt

相关标签:
2条回答
  • 2020-12-11 13:41

    You need to take care of a couple of things:

    • While passing the absolute location of chromedriver binary use a single forward slash along with the raw i.e. r switch. So the effective line of code will be:

      driver = webdriver.Chrome(executable_path=r'C:\chromedriver.exe')
      
    • Execute your @Test as non-administrator / non-root user.


    Update

    Another possible reason is Chrome is not installed in the default location as per the specification:

    Solution

    There can be two approaches to solve this situation:

    • Uninstall Chrome and reinstall Chrome at default location.
    • Use binary_location property to point to the chrome binary location.

      from selenium import webdriver
      from selenium.webdriver.chrome.options import Options
      
      options = Options()
      options.binary_location = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
      driver = webdriver.Chrome(chrome_options=options, executable_path="C:/Utility/BrowserDrivers/chromedriver.exe", )
      driver.get('http://google.com/')
      
    0 讨论(0)
  • 2020-12-11 13:52

    you have to edit

    driver = webdriver.Chrome(executable_path="C:\chromedriver.exe")
    

    to

    driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
    

    you miss \

    If you get the same error, try running as administrator

    or

    move chromedriver.exe to other path like c:/seleniumdriver/chromedriver.exe"and edit executable_path

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