06
Nov

Advanced interactions with WebDriver

In order to generate a sequence of actions, use the Actions generator to build it. First, configure it:

   Actions builder = new Actions(driver);

   builder.keyDown(Keys.CONTROL)
       .click(someElement)
       .click(someOtherElement)
       .keyUp(Keys.CONTROL);

Then get the action:
   Action selectMultiple = builder.build();


And execute it:
   selectMultiple.perform();

The sequence of actions should be short - it's better to perform a short sequence of actions and verify that the page is in the right state before the rest of the sequence takes place. The next section lists all available actions and how can they be extended.