【问题标题】:Chrome webdriver issue in Selenium, python, with linuxSelenium,python,linux中的Chrome webdriver问题
【发布时间】:2019-11-15 09:04:11
【问题描述】:

(最后修改)

我正在用 Python 中的 Selenium 编写一个简单的自动化;我的操作系统是 Mint。问题是我无法打开 Google Chrome 浏览器,版本 75.0.3770.80。

我已尝试为我的浏览器 (75.0.3770.80) 和最新版本安装正确的 webdriver 版本。我也尝试在代码中添加“desiredCapabilities”,但没有奏效。

这是棘手的部分,我已经删除了我在代码上写的任何其他内容,以便更容易看到问题。

from selenium import webdriver
from selenium.webdriver.common.keys import Keys


driver = webdriver.Chrome(executable_path = "/home/pbx/Downloads/gchromedriver/chromedriver")

driver.get("https://google.com")

driver.close()

这段代码应该打开浏览器并访问 google.com,但它甚至没有打开浏览器。这是错误日志

/home/pbx/Documentos/pythomation/venv/bin/python /home/pbx/Documentos/pythomation/ChromeBrowser
Traceback (most recent call last):
  File "/home/pbx/Documentos/pythomation/ChromeBrowser", line 8, in <module>
    driver = webdriver.Chrome(executable_path = "/home/pbx/Downloads/gchromedriver/chromedriver")
  File "/home/pbx/Documentos/pythomation/venv/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
    desired_capabilities=desired_capabilities)
  File "/home/pbx/Documentos/pythomation/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/home/pbx/Documentos/pythomation/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/home/pbx/Documentos/pythomation/venv/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/home/pbx/Documentos/pythomation/venv/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /opt/google/chrome/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)


Process finished with exit code 1

编辑:

Selenium version- 3.141.0
Python version- 3.7.1
Webdriver- chromedriver_linux64.zip 2019-04-30 00:03:36 4.90MB  
ee28a86911127498409dc8623d39ea94

我无法使用旧版 Google Chrome,因为自动化必须测试需要最新版 Chrome 的扩展程序。

所有用户的所有权限都授予驱动程序 (rwx)

【问题讨论】:

  • 驱动程序(ls -ls /home/pbx/Downloads/gchromedriver/chromedriver)的权限是什么?它应该对于启动 selenium 的用户是可执行的...

标签: python linux selenium webdriver selenium-chromedriver


【解决方案1】:

我的 rails 应用程序上的 75.0.3770.80-1 版本的 chrome 和 chromedriver 遇到了同样的问题。我移回了以前的版本,即 chrome 和 chromedriver 的 74.0.3729.169-1,它们工作正常。你可以试试。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-28
    • 1970-01-01
    • 1970-01-01
    • 2021-09-27
    • 2022-01-24
    • 2021-05-27
    • 2017-07-17
    • 2017-09-09
    相关资源
    最近更新 更多