A
A
Agent Gus2018-08-02 14:39:34
open server
Agent Gus, 2018-08-02 14:39:34

Laravel Dusk not working, how to solve this problem?

Hello, I wanted to use tests from Laravel Dusk .
I use laravel on windows with OpenServer (OS) program
I use laravel.loc domain port 80
When I write the command: php artisan dusk
It gives this error:

[email protected] c:\OSPanel\domains\laravel.loc
$ php artisan dusk
Warning: TTY mode is not supported on Windows platform.
PHPUnit 7.2.7 by Sebastian Bergmann and contributors.

RE                                                                  2 / 2 (100%)

Time: 910 ms, Memory: 12.00MB

There was 1 error:

1) Tests\Browser\LoginTest::testExample
TypeError: Argument 1 passed to Facebook\WebDriver\Remote\DesiredCapabilities::__construct() must be of the type array, null given, called in C:\OSPanel\domains\laravel.loc\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php on line 127

C:\OSPanel\domains\laravel.loc\vendor\facebook\webdriver\lib\Remote\DesiredCapabilities.php:33
C:\OSPanel\domains\laravel.loc\vendor\facebook\webdriver\lib\Remote\RemoteWebDriver.php:127
C:\OSPanel\domains\laravel.loc\tests\DuskTestCase.php:39
C:\OSPanel\domains\laravel.loc\vendor\laravel\dusk\src\Concerns\ProvidesBrowser.php:189
C:\OSPanel\domains\laravel.loc\vendor\laravel\framework\src\Illuminate\Support\helpers.php:768
C:\OSPanel\domains\laravel.loc\vendor\laravel\dusk\src\Concerns\ProvidesBrowser.php:190
C:\OSPanel\domains\laravel.loc\vendor\laravel\dusk\src\Concerns\ProvidesBrowser.php:92
C:\OSPanel\domains\laravel.loc\vendor\laravel\dusk\src\Concerns\ProvidesBrowser.php:64
C:\OSPanel\domains\laravel.loc\tests\Browser\LoginTest.php:20

--

There was 1 risky test:

1) Tests\Browser\ExampleTest::testBasicExample
This test did not perform any assertions

ERRORS!
Tests: 2, Assertions: 0, Errors: 1, Risky: 1.

Installed like this:
composer require --dev laravel/dusk
php artisan dusk:install

LoginTest.php
public function testExample()
{
    $this->browse(function (Browser $browser) {
        $browser->visit('/');
    });
}

.env (not complete)
APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:GkMxzBxZNlLvj5Vpt01B+bW6ax9xgHD8ibx0IoiPyKY=
APP_DEBUG=true
APP_URL=http://laravel.loc:80

DuskCaseTest.php
<?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'
        ]);

        return RemoteWebDriver::create(
            'http://laravel.loc:80', DesiredCapabilities::chrome()->setCapability(
                ChromeOptions::CAPABILITY, $options
            )
        );
    }
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question