Laravel Dusk 运行 in Ubuntu 20.04 错误 Chrome 启动失败:异常退出

Laravel Dusk running in Ubuntu 20.04 Error Chrome failed to start: exited abnormally

当我运行

$ php artisan  dusk tests/Browser/ExampleTest.php

提示错误

  1. Tests\Browser\ExampleTest::testExample Facebook\WebDriver\Exception\UnknownServerException: unknown error: Chrome failed to start: exited abnormally (unknown error: DevToolsActivePort file doesn't exist) (The process started from chrome location /snap/bin/chromium is no longer running, so ChromeDriver is assuming that Chrome has crashed.) (Driver info: chromedriver=2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc44e5),platform=Linux 5.4.0-107-generic x86_64)

我检查了 chrome 驱动程序,它安装正确。

$ php artisan dusk:chrome-driver

ChromeDriver binary successfully installed for version 100.0.4896.60.

然后我google报错了。他们说要检查 chrome 版本

$ /usr/bin/chromium-browser --version

/usr/bin/chromium-browser: 12: xdg-settings: not found cannot create user data directory: /home/shiro/snap/chromium/1952: Permission denied

我的目标是 运行 Laravel Dusk Ubuntu 20.04.

***确保您的 chromium-browser 需要删除并安装与您的 Laravel Dusk Chrome 驱动程序匹配的 snap 稳定版本

下面是步骤,我运行:-

接下来通过 snap 安装修复 Chromium 问题,然后是下一个错误

$ sudo snap refresh --edge chromium

error: cannot communicate with server: Post http://localhost/v2/snaps/chromium: dial unix /run/snapd.socket: connect: no such file or directory

要解决错误,需要更新软件包。

$ sudo add-apt-repository ppa:saiarcot895/chromium-beta
$ sudo apt-get update
$ sudo apt-get install chromium-browser

最后,它显示了版本。但是,与我的 Laravel Chrome 驱动程序不匹配。没有解决我的第一个问题。还是不行运行dusk

$ /usr/bin/chromium-browser --version
Chromium 97.0.4692.20 Ubuntu 20.04

接下来安装 Chrome 的 snap 版本并删除 chromium-browser

$ systemctl start snapd.service
$ sudo snap install chromium
$ sudo apt remove chromium-browser

重要提示

$/usr/bin/chromium-browser--版本 -bash: /usr/bin/chrome: 没有那个文件或目录

轰~成功了~