i've project that using dusk for simple admin login testing. everything work's fine when i doing login admin test case on local machine(my own local computer).
here my DuskTestCase.php snippet:
...
protected function driver()
{
$options = (new ChromeOptions)->addArguments([
'--disable-gpu',
'--headless',
'--window-size=1920,1080',
]);
return RemoteWebDriver::create(
'http://localhost:9515', DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
)
);
}
...
my LoginTest.php snippet located in test/Browser:
...
public function testLoginAdmin()
{
$this->browse(function (Browser $browser) {
$browser->visit('/login')
->type('#email', 'admin@admin')
->type('#password', 'admin')
->press('LOGIN')
->assertPathIs('/admin/dasbor');;
});
}
...
here's the output from my local computer:
$ php artisan dusk
Warning: TTY mode is not supported on Windows platform.
PHPUnit 9.2.5 by Sebastian Bergmann and contributors.
DevTools listening on ws://127.0.0.1:63025/devtools/browser/26e3002f-4050-4549-9220-246558a7efd6
. 1 / 1 (100%)
Time: 00:08.528, Memory: 16.00 MB
OK (1 test, 1 assertion)
but it's going error when i run github actions.
my .env.dusk file:
APP_NAME="Pins SmartPJU"
APP_ENV=local
APP_KEY=base64:8CpKYwb2PE3aRhzRUwh3XMg/+VwlLVM1B0AqhyhR8B0=
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000
LOG_CHANNEL=stack
DB_CONNECTION=sqlite
DB_DATABASE=database/database.sqlite
...
///the rest is default
here's the yml:
name: dusk testing
on:
pull_request:
branches: [ master ]
jobs:
laravel-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Copy .env
run: php -r "file_exists('.env') || copy('.env.dusk', '.env');"
- name: Install Dependencies
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Generate key
run: php artisan key:generate
- name: Directory Permissions
run: chmod -R 777 storage bootstrap/cache
- name: Upgrade Chrome Driver
run: php artisan dusk:chrome-driver 70
- name: Start Chrome Driver
run: ./vendor/laravel/dusk/bin/chromedriver-linux > /dev/null 2>&1 &
- name: Run Dusk Tests
run: |
php artisan serve > /dev/null 2>&1 &
chmod -R 0755 vendor/laravel/dusk/bin/
php artisan dusk
and last, the error output
Run php artisan serve > /dev/null 2>&1 &
Warning: TTY mode requires /dev/tty to be read/writable.
PHPUnit 9.2.5 by Sebastian Bergmann and contributors.
E 1 / 1 (100%)
Time: 01:22.789, Memory: 18.00 MB
There was 1 error:
1) Tests\Browser\LoginTest::testLoginAdmin
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http POST to /session/5e36290494b538df79cb44f5a5b7b459/log with params: {"type":"browser"}
Operation timed out after 30001 milliseconds with 0 bytes received
/home/runner/work/pins-pju/pins-pju/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:331
/home/runner/work/pins-pju/pins-pju/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:590
/home/runner/work/pins-pju/pins-pju/vendor/php-webdriver/webdriver/lib/Remote/RemoteExecuteMethod.php:27
/home/runner/work/pins-pju/pins-pju/vendor/php-webdriver/webdriver/lib/WebDriverOptions.php:166
/home/runner/work/pins-pju/pins-pju/vendor/laravel/dusk/src/Browser.php:396
/home/runner/work/pins-pju/pins-pju/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:161
/home/runner/work/pins-pju/pins-pju/vendor/laravel/framework/src/Illuminate/Support/Traits/EnumeratesValues.php:176
/home/runner/work/pins-pju/pins-pju/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:162
/home/runner/work/pins-pju/pins-pju/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:78
/home/runner/work/pins-pju/pins-pju/tests/Browser/LoginTest.php:24
Caused by
Facebook\WebDriver\Exception\WebDriverCurlException: Curl error thrown for http GET to /session/5e36290494b538df79cb44f5a5b7b459/screenshot
Operation timed out after 30001 milliseconds with 0 bytes received
/home/runner/work/pins-pju/pins-pju/vendor/php-webdriver/webdriver/lib/Remote/HttpCommandExecutor.php:331
/home/runner/work/pins-pju/pins-pju/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:590
/home/runner/work/pins-pju/pins-pju/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php:371
/home/runner/work/pins-pju/pins-pju/vendor/laravel/dusk/src/Browser.php:382
/home/runner/work/pins-pju/pins-pju/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:146
/home/runner/work/pins-pju/pins-pju/vendor/laravel/framework/src/Illuminate/Support/Traits/EnumeratesValues.php:176
/home/runner/work/pins-pju/pins-pju/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:147
/home/runner/work/pins-pju/pins-pju/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:70
/home/runner/work/pins-pju/pins-pju/tests/Browser/LoginTest.php:24
ERRORS!
Tests: 1, Assertions: 1, Errors: 1.
##[error]Process completed with exit code 2.
previously, i've trying to change the chrome driver version with php artisan dusk:chrome-driver and php artisan dusk:chrome-driver 70. It's still error.