Reputation: 717
I followed the instructions from here. But I am having this error and can't figure out why.
There was 1 error:
1) Tests\Browser\Auth\LoginTest::testLogin
TypeError: Argument 1 passed to Facebook\WebDriver\Remote\DesiredCapabilities::__construct() must be of the type array, null given, called in /var/www/xxxxxx/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php on line 127
/var/www/xxxxxx/vendor/facebook/webdriver/lib/Remote/DesiredCapabilities.php:33
/var/www/xxxxxx/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:127
/var/www/xxxxxx/tests/DuskTestCase.php:40
/var/www/xxxxxx/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:192
/var/www/xxxxxx/vendor/laravel/framework/src/Illuminate/Support/helpers.php:816
/var/www/xxxxxx/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:193
/var/www/xxxxxx/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:93
/var/www/xxxxxx/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:64
/var/www/xxxxxx/tests/Browser/Auth/LoginTest.php:27
Here is my DuskTestCase
<?php
namespace Tests;
use Laravel\Dusk\TestCase as BaseTestCase;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication;
/**
* Prepare for Dusk test execution.
*
* @beforeClass
* @return void
*/
public static function prepare()
{
static::startChromeDriver();
}
/**
* Create the RemoteWebDriver instance.
*
* @return \Facebook\WebDriver\Remote\RemoteWebDriver
*/
protected function driver()
{
$options = (new ChromeOptions)->addArguments([
'--disable-gpu',
'--headless',
'--no-sandbox', // as suggested in one of the forums but didn't work
'--window-size=1920,1080',
]);
return RemoteWebDriver::create(
'http://localhost:3402', DesiredCapabilities::chrome()->setCapability(
ChromeOptions::CAPABILITY, $options
)
);
}
}
I have installed facebook/webdriver but same error. I am using Ubuntu and Docker. Chrome also isn't my default browser, changing that didn't help. What am I msising here?
Upvotes: 0
Views: 878
Reputation: 26
Browser drivers are downloaded to \vendor\laravel\dusk\bin within your laravel app.
Navigate to the location from your file explorer and run the executable file (depending on your Operating system, mine is Windows and I'm running chromedriver-win.exe). You should see this
This is the port number to use in your DuskTestCase.php file
Also, you need to ensure you set your APP_URL variable in the .env file to the URL accessible from your browser (mine is APP_URL=http://localhost:8888).
Note: I'm not using port 9515 in my .env file.
I hope that helps.
Upvotes: 1