phplaravellaravel-5laravel-5.5laravel-dusk

How can I fill a date input with Laravel Dusk?


I try to fill a date input with Laravel Dusk with this code:

$browser->type('cooked_at', (new Carbon())->format('Y-m-d'));
// ...

But I get this error:

Element must be user-editable in order to clear it

Every other input fields are OK. Just the one with type date fails.

How can I fill a date input with Laravel Dusk?


Solution

  • According to this issue, you have to do something like:

    $today = now();
    $browser->keys('#cooked_at', $today->day)
            ->keys('#cooked_at', $today->month)
            ->keys('#cooked_at', $today->year);
    // ...