1 year ago
#259982
muldev
WSL2 Laravel dusk testing google-chrome driver unable to display site
Laravel Dusk, errors loading google-chrome
I am trying to run tests using Laravel Dusk on a Windows 10 subsystem, WSL2 running Ubuntu. I've followed the installation guides, and I'm stuck at the point after the google-chrome browser is loaded and renders the site:
This is my DuskTestCase.php driver method:
protected function driver()
{
$options = (new ChromeOptions)->addArguments(collect([
])->unless($this->hasHeadlessDisabled(), function ($items) {
return $items->merge([
'--disable-gpu',
// '--headless',
'--window-size=1920,1080'
]);
})->all());
return RemoteWebDriver::create(
$_ENV['DUSK_DRIVER_URL'] ?? 'http://localhost:9515',
DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
)
);
}
Before running the test, I run chromedriver for linux
vendor/laravel/dusk/bin/chromedriver-linux
returns:
Starting ChromeDriver 99.0.4844.51 (d537ec02474b5afe23684e7963d538896c63ac77-refs/branch-heads/4844@{#875}) on port 9515
Next I run any test say AuthTest
php artisan dusk tests/Browser/AuthTest.php
The test cannot render the site: http://localhost:9515
Error in browser:
{"value":{"error":"unknown command","message":"unknown command: unknown command: login","stacktrace":"#0 0x55bf14b857d3 \u003Cunknown>\n#1 0x55bf148e1688 \u003Cunknown>\n#2 0x55bf14932e11 \u003Cunknown>\n#3 0x55bf14932b77 \u003Cunknown>\n#4 0x55bf148b81d4 \u003Cunknown>\n#5 0x55bf148b9020 \u003Cunknown>\n#6 0x55bf14bb649d \u003Cunknown>\n#7 0x55bf14bcf60c \u003Cunknown>\n#8 0x55bf14bb8205 \u003Cunknown>\n#9 0x55bf14bcfee5 \u003Cunknown>\n#10 0x55bf14bac070 \u003Cunknown>\n#11 0x55bf148b7d49 \u003Cunknown>\n#12 0x7f7d460390b3 \u003Cunknown>\n"}}
If I load google-chrome manually and try to go to the same address (http://127.0.0.1:9515/), the same error appears.
However if I close everything and run:
php artisan serve --port 9515
then
google-chrome
I am able to manually interact with the site, yet Laravel Dusk cannot load the browser.
The following error is thrown by Laravel Dusk
```bash
TypeError: Argument 1 passed to Facebook\WebDriver\Remote\DesiredCapabilities::__construct() must be of the type array, null given, called in /home/simon/sites/acquisitionboardgame_vue/vendor/php-webdriver/webdriver/lib/Remote/RemoteWebDriver.php o
n line 648
Can anyone point me in the right direction ?
php
google-chrome
testing
laravel-8
laravel-dusk
0 Answers
Your Answer