我试图用一个URL启动chrome浏览器,浏览器启动后,它什么也不做。
1分钟后我看到如下错误:
Unable to open browser with url: 'https://www.google.com' (Root cause: org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist
(Driver info: chromedriver=2.39.562718 (9a2698cba08cf5a471a29d30c8b3e12becabb0e9),platform=Windows NT 10.0.15063 x86_64) (WARNING: The server did not provide any stacktrace information)
我的配置:
Chrome浏览器:66
ChromeBrowser: 2.39.56
又及,在Firefox中一切都很好
我在Ubuntu 20和Python Selenium上遇到了这个问题,我首先单独下载了chromedriver,然后使用sudo apt install chromium-browser,尽管它们是同一个版本,但这种情况一直发生。
我的修复是使用提供的chrome驱动程序,附带的回购包位于
/snap/bin/chromium.chromedriver
driver = webdriver.Chrome(chrome_options=options, executable_path='/snap/bin/chromium.chromedriver')
日期9/16/2021
在docker托管的ubuntu容器中使用python在本地运行chrome和selenium,一切都很好。当试图运行从Jenkins上面的错误返回WebDriverException:未知错误:DevToolsActivePort
环境:
-Ubuntu21.04在docker容器内,支持RDP访问。
chrome版本:93
解决方案:
在启动浏览器的python文件中,我必须使用以下行设置DISPLAY环境变量:
import os
os.environ['DISPLAY'] = ':10.0'
#DISPLAY_VAR = os.environ.get('DISPLAY')
#print("DISPLAY_VAR:", DISPLAY_VAR)
我遇到了同样的问题,在我的情况下,Linux系统中有两个不同的常见用户userera和userB。
userA第一次运行selinium程序成功启动chrome浏览器,当到达userB时,出现DevToolsActivePort文件不存在的错误。
我尝试了——remote-debug -port=9222选项,但它导致了一个新的异常:
selenium.common.exceptions.WebDriverException: Message: chrome不可达
I run google-chome目录,看到以下错误:
mkdir /tmp/Crashpad/new: Permission denied (13)
我搜索了这个问题,得到了这个:
https://johncylee.github.io/2022/05/14/chrome-headless-%E6%A8%A1%E5%BC%8F%E4%B8%8B-devtoolsactiveport-file-doesn-t-exist-%E5%95%8F%E9%A1%8C/
chrome_options.add_argument(f"--crash-dumps-dir={os.path.expanduser('~/tmp/Crashpad')}")
感谢@johncylee。