'invalid argument (Session info: headless chrome=91.0.4472.77)

i have this error

invalid argument (Session info: headless chrome=91.0.4472.77)

when if try

$browser->visit('/');

but when i try

$browser->visit('https://www.google.com');

there is no any error

    $process = (new ChromeProcess)->toProcess();
    $process->start();
    $options = (new ChromeOptions)->addArguments(['--disable-gpu', '--headless']);
    $capabilities = DesiredCapabilities::chrome()->setCapability(ChromeOptions::CAPABILITY, $options);
    $driver = retry(5, function () use($capabilities) {
        return RemoteWebDriver::create('http://localhost:9515', $capabilities);
    }, 50);
    $browser = new Browser($driver);
// $browser->visit('https://www.google.com');
$browser->visit('/');
$browser->screenshot(base_path('tests/Browser/screenshots/'.date('Y-m-d-H-i-s') . '.png'));
$browser->quit();
$process->stop();
  • Dusk Version: ^6.15
  • Laravel Version: ^8.12
  • PHP Version: 8.0.3


Solution 1:[1]

It doesn't help that the documentation for Dusk is about as bad the developer debugging experience for it is - it's almost as if the devs don't want you to be testing your apps - but for whatever reason I found this buried as an "aside" under the documentation's CI/CD section:

Most Dusk continuous integration configurations expect your Laravel application to be served using the built-in PHP development server on port 8000. Therefore, before continuing, you should ensure that your continuous integration environment has an APP_URL environment variable value of http://127.0.0.1:8000.

I therefore added APP_URL=localhost:8000 to my .env.dusk.local file (again, nothing really to do with CI/CD):

APP_ENV=local
APP_URL=localhost.rc:8000
DB_CONNECTION=sqlite
DB_DATABASE=database/test_db.sqlite

...and sure enough it does fix the error.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Hashim Aziz