This error occurs when Chrome fails to start properly during the execution of Laravel Dusk tests. To resolve this issue, you can try the following steps:
-
Make sure you have the latest version of Chrome installed on your system.
-
Update your Laravel Dusk dependencies by running the following command in your terminal:
composer require --dev laravel/dusk
- Update your ChromeDriver binary by running the following command in your terminal:
php artisan dusk:chrome-driver --update
- If the above steps don't work, you can try specifying the Chrome binary path in your DuskTestCase.php file. Open the file located at
tests/DuskTestCase.phpand add the following code:
use Facebook\WebDriver\Chrome\ChromeOptions;
protected function driver()
{
$options = (new ChromeOptions())->addArguments([
'--disable-gpu',
'--headless',
'--no-sandbox',
'--window-size=1920,1080',
'--disable-dev-shm-usage',
'--disable-extensions',
]);
return RemoteWebDriver::create(
'http://localhost:9515',
DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY,
$options
)
);
}
- If you are using GitHub Actions, make sure you have the necessary setup to run Chrome in a headless environment. You can refer to the GitHub Actions documentation for more information.
By following these steps, you should be able to resolve the "Chrome failed to start: exited abnormally" error when running Laravel Dusk tests.