Radim Bukovský
Radim Bukovský

Reputation: 357

Karate-UI Automation - How to press key without necessity to be in input field (feature file)

How I press key when I am on the page?. E.g.: I need to press "ESC" key or some key combination. In documentation there is description how do this when you are in input field - it works fine. But if I want to press the key button without using input field I am not successful (In feature file: I have tried for example this, but it did not work: driver.input(Key.ENTER) ).

Thank you.

Upvotes: 1

Views: 4053

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

This can be a gap in our implementation, so can you submit an issue, ideally following this process so that we have an example: https://github.com/intuit/karate/tree/develop/examples/ui-test

For the time being, see if you can work-around by firing a key-press event via JS. I am also hoping that if you target the body element it will work for the whole HTML page:

* input('body', Key.ENTER)

Reference for creating keyboard event: https://stackoverflow.com/a/12187302/143475

And some tips on JS in Karate: https://stackoverflow.com/a/60800181/143475

Upvotes: 1

Related Questions