driver.get( "https://www.python.org" ) 不起作用



我正在尝试用python学习Selenium。 所以尝试访问网站但不起作用

from selenium import webdriver
driver = webdriver.Chrome(executable_path="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome")
driver.implicitly_wait(5)
driver.maximize_window()
driver.get("https://www.python.org/")

控制台中的错误:

/usr/local/bin/python3.7 /Users/adeshpande/PycharmProjects/Selenium/Tests/LoginPagesTest.py
Traceback (most recent call last):
File "/Users/adeshpande/PycharmProjects/Selenium/Tests/LoginPagesTest.py", line 6, in <module>
driver = webdriver.Chrome(executable_path="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome")
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/common/service.py", line 111, in assert_process_still_running
% (self.path, return_code)
selenium.common.exceptions.WebDriverException: Message: Service /Applications/Google Chrome.app/Contents/MacOS/Google Chrome unexpectedly exited. Status code was: 0

您正在呼叫webdriver.Chrome中传递 Chrome 浏览器的路径。 您应该将路径传递给ChromeDriver这是一个单独的程序。您可以从 https://chromedriver.chromium.org 下载

下载并安装后,将路径传递到安装它的位置,您应该很高兴!

最新更新