Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulate key with Laravel Dusk (without input element)

I have a page which consists of some disabled inputs, spans and divs.
In the background I wait for pressed keys. Background of this is some memory game.
My problem is, that it turned out to be pretty hard to test.
I know two functions to simulate input: type() and keys(). When I use keys("@someElement", "34"), I get "element not interactable". Similar happens with type() (well that's not surprising as type suggests filling some input).

How can I properly simulate a pressed key without using an active input element?

like image 345
TimSch Avatar asked Feb 20 '19 18:02

TimSch


1 Answers

Use the underlying driver:

$browser->driver->getKeyboard()->sendKeys('a');
$browser->driver->getKeyboard()->sendKeys(\Facebook\WebDriver\WebDriverKeys::ENTER);
like image 78
Jonas Staudenmeir Avatar answered Oct 15 '22 11:10

Jonas Staudenmeir