我正在尝试使用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
答案 0 :(得分:0)
您正在通过电话webdriver.Chrome
将路径传递到Chrome浏览器。
您应该将路径传递到ChromeDriver
,这是一个单独的程序。您可以从https://chromedriver.chromium.org
下载并安装后,将路径传递到安装位置,您应该一切顺利!