Using Advanced User Interactions API for mouse and keyboard events
The Selenium WebDriver's Advanced User Interactions API allows us to perform operations from keyboard events and simple mouse events to complex events such as dragging-and-dropping, holding a key and then performing mouse operations by using the Actions
class, and building a complex chain of events exactly like a user doing these manually.
The Actions
class implements the builder pattern to create a composite action containing a group of other actions.
In this recipe, we will use the Actions
class to build a chain of events to select rows in a table.
How to do it...
Let's create a test to select the multiple rows from different positions in a table using the Ctrl key. We can select multiple rows by selecting the first row, then holding the Ctrl key, and then selecting another row and releasing the Ctrl key. This will select the desired rows from the table.
@Test public void testRowSelectionUsingControlKey() { List<WebElement...