Running Laravel Dusk on Homestead

2019-05-29 04:43发布

I use Homestead Version 1.0.1 and Laravel version 5.4.16. I setup the Laravel dusk by reading the documentation.

But, when I run php artisan dusk by ssh to my homestead. I got an error like the following

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

Is there anyway to fix this

1条回答
Evening l夕情丶
2楼-- · 2019-05-29 04:46

Yes, it can be found on the github pages of Dusk. It is a known issue and they are working to update the next homestead box.

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.

But for now this worked for me: https://github.com/laravel/dusk/issues/50#issuecomment-275155974

Not included in that post but necessary for me: make sure you have following permission set cd vendor/laravel/dusk/bin; chmod 775 *

Steps from the github post: First of all, google-chrome is requried to be installed in guest 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

Next thing is xvfb:

$ sudo apt-get install -y xvfb

Try to start ./vendor/laravel/dusk/bin/chromedriver-linux --port=8888. If you have some errors about loading libraries (libnss3.so, libgconf-2.so.4), try this:

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

When you see

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

Run

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

Also you may want to add your dev domain in guest's /etc/hosts file: 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

查看更多
登录 后发表回答