Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Angela210's avatar

Laravel 11 Dusk and PHPUnit

New to Laravel as well as to end to end testing with browser, trying to use DUSK for browser testing. Take it down to the simplest point with a new project install. Any ideas of a step I missed? I haven't written any code, just using the examples installed.

Setup:

  1. Windows 11 professional machine.
  2. localhost:8000 is being run through php artisan serve no problems getting to the site.

Steps

  1. created a new laravel project with phpunit as the testing suite
  2. ran phpunit sample test it works
  3. followed laravel's site on adding Dusk did the following (https://laravel.com/docs/11.x/dusk#installation)
  4. composer require laravel/dusk --dev
  5. php artisan dusk:install
  6. php artisan dusk:chrome-driver --detect
  7. added DUSK_DRIVER_URL="localhost:8000" to .env file
  8. php artisan dusk

When I debug I find that the following variables have these values:

$response object Facebook\WebDriver\Remote\WebDriverResponse status =0 value =null sessionID =null

$commandExecutor object Facebook\WebDriver\Remote\HttpCommandExecutor commands =array(79) w3cCompliantCommands =array(87) url ="localhost:8000" curl =CurlHandle isW3cCompliant =false

this line is failing RemoteWebDriver.php on line 664 on this assignment. $returnedCapabilities = new DesiredCapabilities($responseValue);

Full Receive error

FAIL Tests\Browser\ExampleTest ⨯ basic example 4.04s
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
FAILED Tests\Browser\ExampleTest > basic example TypeError
Facebook\WebDriver\Remote\DesiredCapabilities::__construct(): Argument #1 ($capabilities) must be of type array, null given, called in C:\Dev\repos\example-phpunit\vendor\php-webdriver\webdriver\lib\Remote\RemoteWebDriver.php on line 664

at vendor\php-webdriver\webdriver\lib\Remote\DesiredCapabilities.php:25 21▕ WebDriverCapabilityType::VERSION => 'browserVersion', 22▕ WebDriverCapabilityType::ACCEPT_SSL_CERTS => 'acceptInsecureCerts', 23▕ ]; 24▕ ➜ 25▕ public function __construct(array $capabilities = []) 26▕ { 27▕ $this->capabilities = $capabilities; 28▕ } 29▕

1 vendor\php-webdriver\webdriver\lib\Remote\DesiredCapabilities.php:25 2 vendor\php-webdriver\webdriver\lib\Remote\RemoteWebDriver.php:664

0 likes
2 replies
LaryAI's avatar
Level 58

The error you're encountering with Laravel Dusk seems to be related to the WebDriver not being able to establish a session with the ChromeDriver. This is often due to configuration issues or the ChromeDriver not running properly. Here are some steps to troubleshoot and resolve the issue:

  1. Ensure ChromeDriver is Running: Make sure that the ChromeDriver is running and accessible. You can manually start it by running the following command:

    php artisan dusk:chrome-driver
    
  2. Check ChromeDriver Version: Ensure that the version of ChromeDriver matches the version of Chrome installed on your machine. You can check your Chrome version by navigating to chrome://settings/help in your browser. Then, download the matching ChromeDriver version from ChromeDriver's official site.

  3. Verify Dusk Configuration: Double-check your .env file to ensure that the DUSK_DRIVER_URL is set correctly. It should point to the URL where the ChromeDriver is running, typically http://localhost:9515.

  4. Update WebDriver and Dusk: Make sure all your packages are up to date. Run the following commands to update your dependencies:

    composer update
    
  5. Check for Port Conflicts: Ensure that no other services are using the same port as the ChromeDriver. By default, it uses port 9515.

  6. Run Dusk with Debugging: Try running Dusk with additional debugging information to get more insights:

    php artisan dusk --debug
    
  7. Firewall and Network Settings: Ensure that your firewall or network settings are not blocking the connection to the ChromeDriver.

  8. Reinstall Dusk: If the above steps do not resolve the issue, try reinstalling Dusk:

    composer remove laravel/dusk
    composer require laravel/dusk --dev
    php artisan dusk:install
    
  9. Check PHP and Laravel Versions: Ensure that your PHP and Laravel versions are compatible with the version of Dusk you are using.

If you follow these steps and the issue persists, consider checking the Laravel Dusk GitHub repository for any open issues or updates that might address this problem.

Angela210's avatar
Angela210
OP
Best Answer
Level 1

Never mind... The DUSK_DRIVER_URL I set needed to be taken away... And the APP_URL in the .env needed to be set with the proper port number.

Now DUSK works

Please or to participate in this conversation.