运行 Laravel Dusk 在 Homestead

Running Laravel Dusk on Homestead

我使用 Homestead 版本 1.0.1Laravel 版本 5.4.16。我通过阅读 the documentation 来设置 Laravel dusk。

但是,当我 运行 php artisan dusk 通过 ssh 连接到我的 homestead 时。我收到如下错误

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

有办法解决这个问题吗?

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

The basic issue is that the homestead box has no visual interface and that dusk runs a real browser, so you have to install a chromedriver if you want to use it.

但现在这对我有用: https://github.com/laravel/dusk/issues/50#issuecomment-275155974

不包括在 post 但对我来说是必要的: 确保您设置了以下权限 cd vendor/laravel/dusk/bin; chmod 775 *

来自 github post 的步骤: 首先,需要在guest中安装google-chrome OS:

$ 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.

This issue is to add the chromedriver to homestead by default and will be solved mid April. https://github.com/laravel/homestead/issues/516