gpt4 book ai didi

python - Selenium 无法在 CentOS 中启动 Chromedriver

转载 作者:行者123 更新时间:2023-12-02 01:06:34 24 4
gpt4 key购买 nike

我尝试使用 Selenium 启动 Chromedriver

from selenium import webdriver
driver = webdriver.Chrome()
driver.get("http://www.google.com/")
print(driver.title)

错误消息如下:

raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.33.506092,platform=Linux 3.10.0-693.5.2.el7.x86_64 x86_64)

我正在使用这些:

[root@jdu4e00u53f7 workspace]# ll /usr/local/bin/chromedriver
lrwxrwxrwx 1 root root 17 11月 14 00:31 /usr/local/bin/chromedriver -> /opt/chromedriver
  • CentOS 7.3
  • python (3.6.2)
  • Selenium (3.7.0)
  • 谷歌浏览器 (62.0.3202.89)
  • chromedriver(2.9)/我改成了chromedriver=2.33.506092
  • Xvfb

ps,我也试过了

  1. driver = webdriver.Chrome('/usr/local/bin/chromedriver'),它不工作...

test.py output

引用:Selenium fails to start Chromedriver

  1. 在我的服务器上,在后台启动 Xvfb:Xvfb :0 -ac -screen 0 1024x768x24 &也没有工作

引用:unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.9

最佳答案

从您提到的配置中可以明显看出您正在使用 Selenium v​​3.7.0Google Chrome 62.0> 以及不兼容的 chromedriver v2.9。因此我们看到错误 WebDriverException: Message: unknown error: Chrome failed to start: exited abnormally

The Release Notes of ChromeDriver v2.33 clearly mentions Supports Chrome v60-62

解决方案:

this link下载最新的chromedriver v2.33并执行您的测试用例。

更新:

试试下面的代码块:

from selenium import webdriver
driver = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()

OR

from selenium import webdriver
driver = webdriver.Chrome(executable_path='/opt/chromedriver')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()

关于python - Selenium 无法在 CentOS 中启动 Chromedriver,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47277655/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com