TypeError:传递给Facebook \ WebDriver \ Remote \ DesiredCapabilities :: __ construct()的参数1必须为数组类型,给定为null,在

时间:2019-08-06 10:30:11

标签: laravel laravel-dusk

Laravel黄昏问题

我的VM站点在http://172.31.71.71:9090上运行 当我尝试运行PHP工匠黄昏时

我的代码

    protected function driver()
{
    $options = (new ChromeOptions)->addArguments([
        '--disable-gpu',
        '--headless',
        '--window-size=1920,1080',
    ]);

    return RemoteWebDriver::create(
        'http://172.31.71.71:9090', DesiredCapabilities::chrome()->setCapability(
            ChromeOptions::CAPABILITY, $options
        )
    );
}

出错         Sebastian Bergmann和贡献者的PHPUnit 7.5.14。

    E                                                                   1 / 1 (100%)

    Time: 99 ms, Memory: 16.00 MB

    There was 1 error:

    1) Tests\Browser\LoginTest::testLogin
    TypeError: Argument 1 passed to Facebook\WebDriver\Remote\DesiredCapabilities::__construct() must be of the type array, null given, called in /var/www/marketplaceoffers.com/www/marketplaceoffers/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php on line 145

    /var/www/marketplaceoffers.com/www/marketplaceoffers/vendor/facebook/webdriver/lib/Remote/DesiredCapabilities.php:33
    /var/www/marketplaceoffers.com/www/marketplaceoffers/vendor/facebook/webdriver/lib/Remote/RemoteWebDriver.php:145
    /var/www/marketplaceoffers.com/www/marketplaceoffers/tests/DuskTestCase.php:37
    /var/www/marketplaceoffers.com/www/marketplaceoffers/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:192
    /var/www/marketplaceoffers.com/www/marketplaceoffers/vendor/laravel/framework/src/Illuminate/Support/helpers.php:817
    /var/www/marketplaceoffers.com/www/marketplaceoffers/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:193
    /var/www/marketplaceoffers.com/www/marketplaceoffers/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:93
    /var/www/marketplaceoffers.com/www/marketplaceoffers/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:64
    /var/www/marketplaceoffers.com/www/marketplaceoffers/tests/Browser/LoginTest.php:21

    ERRORS!
    Tests: 1, Assertions: 0, Errors: 1.
    root@71e3381c1bc4:/var/www/marketplaceoffers.com/www/marketplaceoffers#

1 个答案:

答案 0 :(得分:0)

将“ http://172.31.71.71:9090”更改为“ http://localhost:9515”,

    return RemoteWebDriver::create(
        'http://localhost:9515',
        DesiredCapabilities::chrome()->setCapability(
            ChromeOptions::CAPABILITY,
            $options
        ),
    );