With the recent announcement of Laravel 5.4, I thought I'd give it a try. Like Ozymandias-X on Reddit, I also have been frustrated by it.
My Setup
- Windows 10 as Host;
- CentOS 7 as Guest (no GUI installation, no Vagrant)
- Shared folder with Virtual Box.
If I just turn on my machine and run php artisan dusk
, I get the following:
[08:14 AM]-[root@php7]-[/var/www/html/admin]-[git master]
# php artisan dusk
PHPUnit 5.7.11 by Sebastian Bergmann and contributors.
E 1 / 1 (100%)
Time: 25.91 seconds, Memory: 10.00MB
There was 1 error:
1) Tests\Browser\LoginTest::it_should_see_email_error_message
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"\/usr\/lib64\/chromium-browser\/chromedriver","args":["no-first-run"]}}}
Operation timed out after 5001 milliseconds with 0 out of -1 bytes received
/var/www/html/admin/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:287
/var/www/html/admin/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:121
/var/www/html/admin/tests/DuskTestCase.php:42
/var/www/html/admin/vendor/laravel/dusk/src/TestCase.php:180
/var/www/html/admin/vendor/laravel/framework/src/Illuminate/Support/helpers.php:639
/var/www/html/admin/vendor/laravel/dusk/src/TestCase.php:181
/var/www/html/admin/vendor/laravel/dusk/src/TestCase.php:111
/var/www/html/admin/vendor/laravel/dusk/src/TestCase.php:85
/var/www/html/admin/tests/Browser/LoginTest.php:24
ERRORS!
Tests: 1, Assertions: 1, Errors: 1.
I tried to follow Mike Smith's article, but executing ./vendor/laravel/dusk/bin/chromedriver-linux
manually and commenting out static::startChromeDriver();
from DuskTestCase didn't help at all. I also tried installing Xvfb and running it on port :0 manually and same thing happens.
Lastly, I tried running the driver manually from /usr/lib64/chromium-browser/chromedriver
(2.25) and no change at all.
I'm trying to avoid running this from Windows directly because I intend to have a CI process with a headless/no-gui linux and I'll have to set up the same thing I'm trying right now.
The solution is to either run chrome with
no-sandbox
or NOT run it as root at all. I created a user called dusk and under that Dusk will work with no problems.For anyone else that's running into issues with Dusk in headless mode, give this a try:
In
DuskTestCase
use the following driver function:Did the trick for me :-)
Note: This is not the accepted answer because the real problem is with Cent OS. This answer is just a suggestion while we don't have a solution for RedHat.
The problem is with Cent OS. By doing everything I did on a Ubuntu distribution, it worked easily. This post om medium based on this gist is enough to get anyone going. I'm going to highlight some points here in case the link breaks.
Dependencies
Running the Xvfb
Done