Laravel 8 + Dusk tests: why ->type() cannot find my `email` input?

233 Views Asked by At

See this step

$this->browse(function (Browser $browser) {
    $browser->visit('/login')
        ->type(' email','[email protected]')
    ;
});

My /login route has a classic form with two fields where the first (as testimonied by a ->storeSource() is

<input id="email" type="email" 
      class="form-control form-control-md rounded-0" 
      name="email" value="" required="">

Running the test, it fails

Facebook\WebDriver\Exception\NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"body email"

Questions

Why my input tag with id and name set as email cannot be find?

How to fix?

1

There are 1 best solutions below

0
On BEST ANSWER

Damn, stupid typo.

I fixed by myself changing

->type(' email','[email protected]')

into

->type('email','[email protected]')