Error when testing with Laravel Dusk

Asked

Viewed 119 times

0

Good morning guys, has anyone ever had experience with Laravel Dusk who can help me? I can not do the Authentication by Browser to be able to access the screens, in my case I have different Wards, but according to the documentation what I am doing should work.. Follow the Test Code below:

public Function testLogin() { $manager = Factory(Manager::class)->create();

   $this->browse(function (Browser $browser) use ($manager) {
       $browser->visit($this->getUrl().'manager/login')
           ->type('email', $manager->email)
           ->type('password', '123123')
           ->press('Entrar')
           ->assertPathIs('/manager/home')
           ->assertSee('Inicio');
   });

}

The error is as follows:

There was 1 error:

1) Tests Browser Managertest::testLogin Facebook Webdriver Exception Nosuchelementexception: no such element: Unable to locate element: {"method":"css selector","selector":"body textarea[name='email']"} (Session info: headless Chrome=66.0.3359.181) (Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),Platform=Windows NT 10.0.17134 x86_64) (edited)

1 answer

0


I was able to find the mistake.

In my file . env needed to put APP_URL=http://127.0.0.1:8000 , because I realized that it inserts the url in front. so the code was like this.

   $this->browse(function (Browser $browser) use ($manager) {
        $browser->visit('/manager/login')
            ->type('email', $manager->email)
            ->type('password', '123123')
            ->press('Entrar')
            ->assertPathIs('/manager/home')
            ->assertSee('Inicio');
   });

I visited some references that form of great importance:

https://laracasts.com/discuss/channels/laravel/laravel-dusk-example-auth-test-not-workin?page=1

https://scotch.io/tutorials/introduction-to-laravel-dusk

Vlw.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.