When I try to execute the Dusk tests in Laravel Homestead I get the “unknown error: cannot find Chrome binary” error.
$ php artisan dusk
PHPUnit 8.5.5 by Sebastian Bergmann and contributors.
E 1 / 1 (100%)
Time: 1.85 seconds, Memory: 18.00 MB
There was 1 error:
1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\UnknownErrorException: unknown error: cannot find Chrome binary
/home/vagrant/code/web/wp-polyglots-facilitator/vendor/php-webdriver/webdriver/lib/Exception/WebDriverException.php:139
/home/vagrant/code/web/wp-polyglots-facilitator/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:370
/home/vagrant/code/web/wp-polyglots-facilitator/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:136
/home/vagrant/code/web/wp-polyglots-facilitator/tests/DuskTestCase.php:40
/home/vagrant/code/web/wp-polyglots-facilitator/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:200
/home/vagrant/code/web/wp-polyglots-facilitator/vendor/laravel/framework/src/Illuminate/Support/helpers.php:393
/home/vagrant/code/web/wp-polyglots-facilitator/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:201
/home/vagrant/code/web/wp-polyglots-facilitator/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:95
/home/vagrant/code/web/wp-polyglots-facilitator/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:65
/home/vagrant/code/web/wp-polyglots-facilitator/tests/Browser/ExampleTest.php:21
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
The solution is simple. Install the Chrome binary with the next commands:
sudo apt update && sudo apt install chromium-browser -y
You can also do this with this Artisan command:
php artisan dusk:chrome-driver