我正在尝试使用 selenium 和 python 在 Linux 3.10.0-327.36.3.el7 中启动 chrome 驱动程序。还从chrome documentation获得了一些有用的帮助,我的提取代码片段是
chromedriver = "/path/to/bin/chromedriver"
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chromedriver,
service_log_path = service_log_path, service_args=service_args)
但是我收到以下错误消息,
Message: unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 3.10.0-327.36.3.el7
我在代码中没有发现问题(据我所知),请帮助我修复。
最佳答案
不确定您是否使 chromedriver 可执行(在 Ubuntu/Linux/Mac 系统上)。如果你不这样做,你的 chromedriver 将无法工作。
请尝试这个 - 如果你还没有
chmod +x chromedriver
chmod 777 chromedriver
然后再试一次。我为此编写了一个简单的脚本,并且能够完美地启动我的 chrome -
import os
from selenium import webdriver
chrome_path="/home/rahul/Documents/SeleniumPy/chromedriver" //this is my chromedriver path
driver=webdriver.Chrome(chrome_path)
driver.maximize_window()
driver.implicitly_wait(30)
driver.get('http://www.google.com')
driver.quit()
关于 python : Selenium - Message: unknown error: Chrome failed to start: exited abnormally,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43354429/