Selenium driver.get()引发异常

时间:2018-06-25 19:24:42

标签: python google-chrome selenium selenium-chromedriver

当我运行此代码时:

from selenium import webdriver
import time

driver = webdriver.Chrome('C:/Program Files 
(x86)/Google/Chrome/Application/chrome.exe')
driver.get('https://www.google.com/')

它只会打开我的浏览器,而不会打开作为参数传递给driver.get()的URL。

以下是追溯:

Traceback (most recent call last):
  File "C:\Users\efiqq\OneDrive\Plocha\Python\Link.py", line 4, in <module>
    driver = webdriver.Chrome('C:/Program Files (x86)/Google/Chrome/Application/chrome.exe')
  File "C:\Users\efiqq\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__
    self.service.start()
  File "C:\Users\efiqq\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 98, in start
    self.assert_process_still_running()
  File "C:\Users\efiqq\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\common\service.py", line 111, in assert_process_still_running
    % (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service C:/Program Files (x86)/Google/Chrome/Application/chrome.exe unexpectedly exited. Status code was: 0

1 个答案:

答案 0 :(得分:2)

您必须通过的路径不是chrome.exe。您必须指向chromedriver.exe;

您可以在这里获取它:http://chromedriver.chromium.org/downloads