laravel/dusk

Dusk fails to connect to local server

wq9578 opened this issue · 6 comments

Suddenly Laravel Dusk fails to connect to the local server.
Connecting to remote server still works.
Uninstalling and re-installing doesn't help.

Error message

   PHPUnit\Framework\ExceptionWrapper 

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

Failed to connect to localhost port 9515 after 0 ms: Couldn't connect to server

  at vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:346
    342▕             if (is_array($params) && !empty($params)) {
    343▕                 $msg .= sprintf(' with params: %s', json_encode($params, JSON_UNESCAPED_SLASHES));
    344▕             }
    345▕ 
  ➜ 346▕             throw new WebDriverCurlException($msg . "\n\n" . $error);
    347▕         }
    348▕ 
    349▕         $results = json_decode($raw_results, true);
    350▕ 



  Tests:  1 failed
  Time:   0.24s

Local server start up before running the test with Laravel Dusk:

➜  php artisan serve

   INFO  Server running on [http://127.0.0.1:8000].  

  Press Ctrl+C to stop the server

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

I tested the following (which didn't work):

  1. Installing Chromium with Brew on a Mac with brew install --cask chromium): https://stackoverflow.com/a/67239222
  2. Running php artisan dusk:install and then re-opening the terminal window: #649 (comment)

Solution here: #1017

i have the same issue, just installed today and same error:

`PHPUnit 9.5.27 by Sebastian Bergmann and contributors.

E 1 / 1 (100%)

Time: 00:00.482, Memory: 24.00 MB

There was 1 error:

  1. Tests\Browser\ExampleTest::testBasicExample
    Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"args":["--window-size=1920,1080","--disable-gpu","--headless"]}}]},"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"args":["--window-size=1920,1080","--disable-gpu","--headless"]}}}

Failed to connect to localhost port 8000 after 0 ms: Couldn't connect to server

/var/www/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:346
/var/www/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:134
/var/www/tests/DuskTestCase.php:44
/var/www/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:219
/var/www/vendor/laravel/framework/src/Illuminate/Support/helpers.php:247
/var/www/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:220
/var/www/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:98
/var/www/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:66
/var/www/tests/Browser/ExampleTest.php:19

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
`

Note - this can happen after deleting all comments in DuskTestCase.php. The @beforeClass directive above provide ensures that the chrome driver is started before tests starts.