在Homestead上运行Laravel Dusk

3
我使用Homestead版本1.0.1和Laravel版本5.4.16。我通过阅读文档安装了Laravel dusk。但是,当我通过ssh运行php artisan dusk时,我遇到了以下错误:
PHPUnit 5.7.17 by Sebastian Bergmann and contributors. E 1 / 1 (100%) Time: 2.52 minutes, Memory: 10.00MB There was 1 error: 1) Tests\Browser\ExampleTest::testBasicExample Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"","args":["no-first-run"]}}} Operation timed out after 30001 milliseconds with 0 bytes received
有没有什么方法可以解决这个问题?
1个回答

6

是的,可以在Dusk的github页面上找到。这是一个已知问题,他们正在努力更新下一个homestead box。

基本问题是homestead box没有可视界面,而dusk运行一个真正的浏览器,所以如果您想使用它,必须安装chromedriver。

但是目前对我来说这个方法有效: https://github.com/laravel/dusk/issues/50#issuecomment-275155974

该帖子中未包含但对我必要的内容: 确保您拥有以下权限设置cd vendor/laravel/dusk/bin; chmod 775 *

github帖子的步骤: 首先,在guest OS中需要安装google-chrome:

$ wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
$ sudo sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list'
$ sudo apt-get update && sudo apt-get install -y google-chrome-stable

接下来要介绍的是xvfb:

$ sudo apt-get install -y xvfb

尝试启动./vendor/laravel/dusk/bin/chromedriver-linux --port=8888。如果您遇到有关加载库(libnss3.so、libgconf-2.so.4)的错误,请尝试以下方法:

$ sudo apt-get install -y libnss3-dev libxi6 libgconf-2-4

当你看到

$ ./vendor/laravel/dusk/bin/chromedriver-linux --port=8888
Starting ChromeDriver 2.25.426924 (649f9b868f6783ec9de71c123212b908bf3b232e) on port 8888
Only local connections are allowed.
this means ChromeDriver can be started (so SupportsChrome trait should be able to start it too). You can stop this process for now (Ctrl+C).

运行

$ Xvfb :0 -screen 0 1280x960x24 &
in a separate terminal window.

另外,您可能需要在访客的/etc/hosts文件中添加开发域名: 127.0.0.1 domain.dev。

这个问题是默认在Homestead中添加chromedriver,并将在4月中旬解决。 https://github.com/laravel/homestead/issues/516


我按照建议安装了google-chrome-stable,成功运行而没有依赖问题的抱怨,使用了您提供的参数启动了xvfb命令,但是我仍然遇到了超时错误...我正在尝试在macOS主机上的Debian jessie容器中运行Dusk。从主机操作系统上,Dusk能够启动浏览器。容器中的chromedriver-linux权限为755。 - Spencer Williams

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接