我试图用一个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中一切都很好
正如在另一个答案中所述:
此错误消息…这意味着ChromeDriver无法启动/生成一个新的WebBrowser,即Chrome浏览器会话。
Among the possible causes, I would like to mention the fact that, in case you are running an headless Chromium via Xvfb, you might need to export the DISPLAY variable: in my case, I had in place (as recommended) the --disable-dev-shm-usage and --no-sandbox options, everything was running fine, but in a new installation running the latest (at the time of writing) Ubuntu 18.04 this error started to occurr, and the only possible fix was to execute an export DISPLAY=":20" (having previously started Xvfb with Xvfb :20&).
TL;DR:如果你使用VirtualBox共享文件夹,不要在那里创建Chrome配置文件!
我在Debian 10下遇到了这个错误,但在Ubuntu 18.04下没有发生。
在我的Selenium测试中,我想安装一个扩展,并使用以下Chrome选项:
chromeOptions.addArguments(
`load-extension=${this.extensionDir}`,
`user-data-dir=${this.profileDir}`,
`disable-gpu`,
`no-sandbox`,
`disable-setuid-sandbox`,
`disable-dev-shm-usage`,
);
问题是,我试图在一个非标准目录下创建一个Chrome配置文件,这是VirtualBox共享文件夹的一部分。尽管使用的是完全相同版本的Chrome和Chromedriver,但在Debian下却无法运行。
解决方案是在其他地方选择一个概要目录(例如~/chrome-profile)。
我遇到了同样的问题,在我的情况下,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。