【问题标题】:TypeError: Argument 1 passed to Facebook\WebDriver\Remote\DesiredCapabilities::__construct() must be of the type array, null given, called inTypeError: 传递给 Facebook\WebDriver\Remote\DesiredCapabilities::__construct() 的参数 1 必须是数组类型,给定 null,调用
【发布时间】:2019-12-13 21:19:31
【问题描述】:

Laravel 黄昏问题

我的虚拟机站点在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#

【问题讨论】:

标签: laravel laravel-dusk


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-04
    • 2020-01-06
    • 1970-01-01
    相关资源
    最近更新 更多