The keyDown and keyUp actions

The keyDown() method is used to simulate the action of pressing and holding a key. The keys that we are referencing here are the Shift, Ctrl, and Alt keys. The keyUp() method is used to release the key that is already pressed using the keyDown() method. The API syntax for the keyDown() method is as follows:

public Actions keyDown(Keys theKey) throws IllegalArgumentException

An IllegalArgumentException is thrown when the passed key is not one of the Shift, Ctrl, and Alt keys. The API syntax for the keyUp() method is as follows:

public Actions keyUp(Keys theKey)

The keyUp action performed on a key, on which a keyDown action is not already being performed, will result in some unexpected results. So, we have to make ...

Get Selenium WebDriver 3 Practical Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.