I have been following this info https://laravel.com/docs/10.x/sail#laravel-dusk to get dusk to work with sail.

When I try to run a dusk test with: sail dusk

... I get: Failed to connect to localhost port 9515 after 0 ms: Connection refused

Facebook\WebDriver\Exception\Internal\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"args":["--window-size=1920,1080"]}}]},"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"args":["--window-size=1920,1080"]}}}

what do you think this is?

I am on a mac, with Firefox as default browser. Nothing of this should matter (right?) since I use sail and are using a dockerized local env.

3

There are 3 best solutions below

0
Mehran On

Make sure you have selenium defined in your docker-compose.yml. If not, follow documentation here: https://laravel.com/docs/10.x/sail#laravel-dusk

Also you need to run "sail dusk" instead of "sail artisan dusk".

1
Jon White On

This could be an SSL thing.

The simplest way to check would be to edit your driver() method in tests/DuskTestCase.php to allow your web driver to accept insecure certificates.

return RemoteWebDriver::create(
    env('DUSK_DRIVER_URL', 'http://selenium:4444/wd/hub'),
    DesiredCapabilities::chrome()->setCapability(
        ChromeOptions::CAPABILITY,
        $options
    )->setCapability('acceptInsecureCerts', true)
);

If that solves it you can either keep it like that review your SSL cert config

On miken32's suggestion. Please note that acceptInsecureCerts should only be used for testing purposes.

0
Julian On

It seems that your host isn't able to access dusk. Be sure that you bind the port correctly in you docker-compose.yml

services:
  app:
    ...
    ports:
      - 9515:9515