【发布时间】:2018-11-15 17:36:44
【问题描述】:
我已经使用 python 和 selenium 有一段时间了,但是在使用无头版本的 chrome 驱动程序时突然出现这个错误。
这是我一直使用的代码示例;
from selenium import webdriver
chrome_options = Options()
chrome_options.add_argument("--headless")
driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver',chrome_options=chrome_options)
###Function that my code does###
driver.quit()
我得到的错误是:
browser = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver',chrome_options=chrome_options)
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
File "/usr/local/lib/python2.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 /usr/local/bin/chromedriver unexpectedly exited. Status code was: 1
现在我试图通过谷歌找到一个解决方案,但结果表明将 chromedriver 放在路径中并在 python 代码本身中定义该路径。但是所有这些事情都已经完成了,我在这里犯了什么愚蠢的错误?
【问题讨论】:
标签: python selenium selenium-chromedriver