I'm wondering if there is any way to test for where focus is set on a page, using Laravel Dusk. I have a form whose first element should always receive focus when the page loads. I don't see anything obvious in the Dusk documentation for this. I'm using Laravel 5.5.
Use this:
$element = $browser->element($selector);
$this->assertTrue($browser->driver->switchTo()->activeElement()->equals($element));
UPDATE: In Dusk 3.0.8 you can use assertFocused()
and assertNotFocused()
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With