so i've been trying to setup Laravel with Gitlab, everything works fine now, however when the script tries to run my Browser tests, i get the following error
Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"binary":"","args":["--disable-gpu","--headless","--window-size=1920,1080"]}}]},"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"binary":"","args":["--disable-gpu","--headless","--window-size=1920,1080"]}}}
Failed to connect to localhost port 9515: Connection refused
at vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:331
here is my .gitlab-ci.yml file
before_script:
- apt-get update
- apt-get install -qq git curl libmcrypt-dev libjpeg-dev libpng-dev libfreetype6-dev libbz2-dev
- apt-get install zlib1g-dev libzip-dev
- apt-get clean
- curl --silent --show-error https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
- docker-php-ext-install pdo_mysql zip
- cp .env.test .env
image: php:7.3
services:
- mysql:5.7
variables:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: homestead
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
DB_HOST: mysql
DB_USERNAME: root
stages:
- test
browser_test:
stage: test
script:
- echo "Starting pest tests"
- composer install
- php artisan dusk:install
- php artisan dusk:chrome-driver
- php artisan key:generate
- php artisan migrate
- php artisan serve & vendor/bin/pest
and this is my .env.test file
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
APP_URL=http://localhost
DB_CONNECTION=mysql
DB_HOST=mysql
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
from what i could find is that the chrome-driver is'nt running,
Thanks for your answer.
the problem is solved by adding --no-sandbox to the chrome-driver setup
in tests/DuskTestCase.php add this
protected function driver()
{
$options = (new ChromeOptions)->addArguments([
'--disable-gpu',
'--headless',
'--window-size=1920,1080',
'--no-sandbox', <---------------------
]);
return RemoteWebDriver::create(
'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
)
);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With