简体   繁体   English

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

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

(edits in the end) (最后修改)

I'm codng a simple automation with Selenium in Python;我正在用 Python 中的 Selenium 编写一个简单的自动化; my operating system is Mint.我的操作系统是 Mint。 The issue is that I can't get it to open the Google Chrome browser, version 75.0.3770.80.问题是我无法打开 Google Chrome 浏览器,版本 75.0.3770.80。

I've tried installing both de correct webdriver version for my browser (75.0.3770.80) and the latest version.我已经尝试为我的浏览器 (75.0.3770.80) 和最新版本安装正确的 webdriver 版本。 I've tried adding "desiredCapabilities" to the code too, but didn't work.我也尝试在代码中添加“desiredCapabilities”,但没有奏效。

Here's the tricky part, I've removed any other things I wrote on the code so it becomes easier to see the problem.这是棘手的部分,我删除了我在代码上写的任何其他内容,以便更容易看到问题。

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()

This fragment of the code should open the browser and go to google.com, but it doesn't even open the browser.这段代码应该会打开浏览器并转到 google.com,但它甚至不会打开浏览器。 Here's the error log这是错误日志

/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

Edit:编辑:

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

I can't use and older version of Google Chrome because the automation must test an extension that requires the latest Chrome version.我无法使用旧版本的 Google Chrome,因为自动化必须测试需要最新 Chrome 版本的扩展程序。

All permissions are granted to the driver (rwx) for all users所有用户的所有权限都授予驱动程序 (rwx)

I had the same issues with 75.0.3770.80-1 versions of chrome and chromedriver on my rails app.我的 rails 应用程序上的75.0.3770.80-1版本的 chrome 和 chromedriver 也遇到了同样的问题。 I moved back to the previous versions ie 74.0.3729.169-1 for both chrome and chromedriver, and they worked.我搬回到以前版本的IE 74.0.3729.169-1 Chrome和chromedriver,和他们的工作。 You can try that.你可以试试。

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

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