[英]WebDriverException: Message: Service /usr/bin/google-chrome unexpectedly exited. Status code was: -11 with ChromeDriver Chrome through Selenium Python
[英]selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/google-chrome unexpectedly exited with ChromeDriver Selenium Python on Linux
from selenium import webdriver
driver = webdriver.Chrome(executable_path=r'/usr/local/bin/google-chrome')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()
我收到此错误:
File "test.py", line 5, in <module>
driver = webdriver.Chrome(executable_path=r'/usr/bin/google-chrome')
File "/usr/local/python3/lib/python3.6/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/usr/local/python3/lib/python3.6/site-packages/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
File "/usr/local/python3/lib/python3.6/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/bin/google-chrome unexpectedly exited. Status code was: 1
我尝试了互联网上的其他解决方案,但我尝试的每个解决方案都收到了一个新错误。 我只想使用 python selenium 和 chrome 驱动程序获取页面源,我不知道为什么没有解决方案对我有用,有什么帮助吗?
我在客户端 - 服务器中执行此操作,在我的本地即时消息中使用 Windows 并且它的工作良好,但是它的代码不同......
这个错误信息...
selenium.common.exceptions.WebDriverException: Message: Service /usr/bin/google-chrome unexpectedly exited. Status code was: 1
...暗示ChromeDriver无法启动/生成新的浏览上下文,即Chrome 浏览器会话。
看来你已经很接近了。 通过Key executable_path
而不是google-chrome
二进制executable_path
的绝对路径,您需要将ChromeDriver的绝对路径作为Value传递。 如此有效,您需要替换以下代码行:
driver = webdriver.Chrome(executable_path=r'/usr/local/bin/google-chrome')
和:
driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
安装此软件包并重试:
apt-get install -y libglib2.0-0=2.50.3-2 \
libnss3=2:3.26.2-1.1+deb9u1 \
libgconf-2-4=3.2.6-4+b1 \
libfontconfig1=2.11.0-6.7+b1
或者您可以安装铬浏览器:
sudo apt-get install -y chromium-browser
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.