The Advanced User Interactions API is a new, more comprehensive API for describing actions a user can perform on a web page. Normally, we need to find elements and then send actions through them. If we need to perform complex tasks such as holding down Ctrl and clicking, then this may not work.
The Advanced User Interactions allows us to build these complex interactions with elements in a really nice API. The API relies on two key interfaces for the interactions to work—keyboard and mouse.
The keyboard interface allows keys to be pressed, held down, and released. It also allows for normal typing.
The methods available are:
void sendKeys(CharSequence... keysToSend)
: This is similar to the existingsendKeys(...)
method.void pressKey(Keys keyToPress)
: This sends a key press only, without releasing it. This should only be implemented for modifier keys (Control, Alt, and Shift).void releaseKey(Keys keyToRelease)
: This releases a modifier key.