Search code examples
laravelselenium-chromedriverplesklaravel-dusk

Laravel Dusk Testing has an error on the server Curl error thrown for http POST to /session with params


I would like to ask me to try the following instructions on Plesk Server:

php artisan dusk

The following error will occur:

1) Tests\Browser\ExampleTest::testBasicExample
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session with params: {"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary" :".\/vendor\/laravel\/dusk\/bin\/chromedriver-linux","args":["--disable-gpu","--headless","--no-sandbox"," --verbose","--window-size=1024,768"]}}}

Failed connect to localhost:9515; Connection refused

/var/www/vhosts/fanswoo.com/fanswoo-framework/vendor/facebook/webdriver/lib/Remote/HttpCommandExecutor.php:292
/var/www/vhosts/fanswoo.com/fanswoo-framework/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:126
/var/www/vhosts/fanswoo.com/fanswoo-framework/tests/DuskTestCase.php:43
/var/www/vhosts/fanswoo.com/fanswoo-framework/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:192
/var/www/vhosts/fanswoo.com/fanswoo-framework/vendor/laravel/framework/src/Illuminate/Support/helpers.php:754
/var/www/vhosts/fanswoo.com/fanswoo-framework/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php: 193
/var/www/vhosts/fanswoo.com/fanswoo-framework/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:93
/var/www/vhosts/fanswoo.com/fanswoo-framework/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:64
/var/www/vhosts/fanswoo.com/fanswoo-framework/tests/Browser/ExampleTest.php:22

I suspected that the Chrome Driver could not be executed, so I used the following command to detect:

./vendor/laravel/dusk/bin/chromedriver-linux

The return is as follows:

Starting ChromeDriver 2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d) on port 9515 Only local connections are allowed.

Indicates that ChromeDriver can be opened normally. The code can also be detected on the local computer. Only when the dusk command is executed in Plesk Server will the error occur. May I ask what God should I continue to do or what to modify? Thank you!

The server specifications are as follows:

CentOS 7.5

PHP 7.1

DB SQLite3

Laravel Version 5.7

ChromeDriver Version 69


Solution

  • If you able to start chromedriver successfully, now try to access the below url with respective port. http://localhost:{port}/status

    For e.g., in above message, the server started on port 9515. Access the url in browser, http://localhost:9515/status

    enter image description here

    You should get above message indicating server is accessible with hostname as localhost

    If your are not able access, then fix the specific issue