0
votes

I just discovered Laravel Dusk, and wrote first test, which had to check for text on the page, but Laravel Dusk doesn`t see my page.

Test:

namespace Tests\Browser;
use Tests\DuskTestCase;
use Laravel\Dusk\Browser;
use Illuminate\Foundation\Testing\DatabaseMigrations;
class FirstTest extends DuskTestCase
{
    public function testExample()
    {
        $this->browse(function (Browser $browser) {
            $browser->visit('/')
                ->assertSee('Laravel');
        });
    }
}

And $browser->visit('/') check is successful, but $browser->visit('/') ->assertSee('Laravel'); check was failed.

In directory tests/Browser/Screenshots I found screenshot that page, which contains No input file specified

a part of file .env:

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:lypVdWwGkDn/R5L5PQ8tOUgfzf2WTzCSZU6GndMPuNM=
APP_DEBUG=true
APP_URL=http://127.0.0.1

After added file .env.dusk.local which contains:

APP_URL=http://127.0.0.1:9519

(As specified in the Laravel Dusk manual , the port must match the one specified in DuskTestCase.php)

tests/Browser/screenshots/failed-test-* contains: command:

Error text:

Time: 2.58 seconds, Memory: 12.00MB

There was 1 failure:

1) Tests\Browser\FirstTest::testExample
Did not see expected text [Laravel] within element [body].
Failed asserting that false is true.

/home/vagrant/code/homestead_test/vendor/laravel/dusk/src/Concerns/MakesAssertions.php:400 /home/vagrant/code/homestead_test/vendor/laravel/dusk/src/Concerns/MakesAssertions.php:371 /home/vagrant/code/homestead_test/tests/Browser/FirstTest.php:18 /home/vagrant/code/homestead_test/vendor/laravel/dusk/src/Concerns/ProvidesBrowser.php:67 /home/vagrant/code/homestead_test/tests/Browser/FirstTest.php:19

FAILURES! Tests: 1, Assertions: 1, Failures: 1.

Sorry for my English =)

UPD:

a part of .env.dusk.local after deleting port: (for Jonas Staudenmeir).

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:lypVdWwGkDn/R5L5PQ8tOUgfzf2WTzCSZU6GndMPuNM=
APP_DEBUG=true
APP_URL=http://127.0.0.1
3
It should be APP_URL=http://127.0.0.1 in your .env.dusk.local file (without the port).Jonas Staudenmeir
@JonasStaudenmeir, no, it doesn`t work.vladimirch
In what environment are you running Dusk? Are you using a virtual machine like Homestead?Jonas Staudenmeir
@JonasStaudenmeir, Yesvladimirch
Are you running Dusk on your host machine (e.g. Windows or Mac OS) or in Homestead (via SSH)?Jonas Staudenmeir

3 Answers

0
votes

Solved. I changed .env.dusk.local (was set virtual host domain), and it's working.

e.g. APP_URL=http://homestead.test

Special thanks to @Jonas Staudenmeir

0
votes

If Test fails on laravel desk it given me a random page of phpmyadmin on screenshot page.It must give me the page on which its giving an error.Please see the page bellow. Click Here.

0
votes

There is a few ways you can try:

1.make sure copy ".env" rename ".env.dusk.local" and change APP_URL={http://localhost:8000} //you serve 2. run php artisan serve 3. run php artisan dusk Time: 2.17 seconds, Memory: 18.00 MB

OK (1 test, 1 assertion)

debug: 1.change DuskTestCase.php to see what website page you browse http://localhost:9515 , DesiredCapabilities::chrome()

2.add one line in your test file ExampleTest.php pause(1000)