Actions class is based on builder design pattern which builds a composite actions with the aggregation of Selenium WebDriver, where webdriver is only used to identify the presence of web elements on web application
Action interface is only used to represent the single user interaction i.e to perform the series of action items build by Actions class.
Example:-
Let's Assume we want to Sent text in Caps in Text field. We need to Press SHIFT and then send Text and then we will release from SHIFT key.
Performing all the task at a time using Selenium API we will use Actions class and Action interface.
1) Actions actions = new Actions(webdriver object);
Since we need to perform all action one by one like this "actions.
2) keyDown(element, Keys.SHIFT) + sendKeys(“Text_In_UpperCase”) + keyUp(Keys.SHIFT)".
we can clubbed all action together as below.
3) actions.keyDown(element, Keys.SHIFT).sendKeys(“Text_In_UpperCase”).keyUp(Keys.SHIFT);
Now,We need to build this sequence using the build() method of Actions class and get the composite action.
4) Action action = actions.build();
Keep in mind that the build method always returns “Action type object” so we need to create reference of Action Interface and hold all builder's Actions.
And finally, perform the actions sequence using perform() method of Action Interface.
5) action.perform();
In short we can use:-
actions.keyDown(element, Keys.SHIFT).sendKeys(“Text_In_UpperCase”).keyUp(Keys.SHIFT).build().perform();