Search code examples
phplaravelformslaravel-dusk

Cannot test input type datetime-local with Larave Dusk


I have following code in my form. I need to let user input date and time.

<input type="datetime-local" class="form-control" id="collection_datetime" name="collection_datetime" required>

When trying to automatically test form with Laravel Dusk I will always get an error.

form error

This is what I tried this

 ->type('collection_datetime', Carbon::now()->format('Y-m-d\TH:i'))
->type('collection_datetime', '12/31/2019 12:59 PM')

non of it worked. Any suggestion you can give me is appreciated. Thank you


Solution

  • This is what worked, I hope it will help someone. It seems to me non-trivial I hope there is prettier solution

                    ->type('collection_datetime', '13')
                    ->type('collection_datetime', 'sep')
                    ->keys('#collection_datetime', ['{tab}'])
                    ->type('collection_datetime', '2019')
                    ->keys('#collection_datetime', ['{tab}'])
                    ->type('collection_datetime', '0104AM')