Sending Keystrokes to Protractor

This post is part of a ten-part series on how to write better Protractor tests. You can find the rest of the series here.

And last but not least, did you know you can send raw keystrokes to your browser? In our apps, we often use a library like mousetrap to implement keyboard shortcuts. But these can be hard to test because you’re not clicking or typing in an element to use them.

Here’s how you can send a specific keystroke to your browser:

There are a variety of protractor.Keys you can use: ENTER, SHIFT, TAB and so on.

Learn Protractor in a few hours with our online course

Protractor is a one of the best ways to ensure your app is working correctly because you can write code that acts like a real user. But Protractor can also be confusing and difficult to work with when you're just starting out. We've put together an online course that will help you become a master at Protractor.

You'll save tons of time and frustration learning Protractor because we've worked out everything you need to know. Become a Protractor testing master today!