繁体   English   中英

Selenium、python 和 linux 中的 Chrome 网络驱动程序问题

[英]Chrome webdriver issue in Selenium, python, with linux

(最后修改)

我正在用 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)

我的 rails 应用程序上的75.0.3770.80-1版本的 chrome 和 chromedriver 也遇到了同样的问题。 我搬回到以前版本的IE 74.0.3729.169-1 Chrome和chromedriver,和他们的工作。 你可以试试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM