Selenium Composite Actions Video Tutorial

You are here:

Automation engineers, Chris Lawson and Ryan Eisma, demonstrate how to modify Selenium composite actions for complex user interactions.

 
 

“A lot of times you will have more complex user interactions than just typing a field and clicking a button.” – Chris Lawson, Automation Engineer

This video will demonstrate how to do, for instance, a drag and drop and a mouse over type event. Follow video times to match demo to summary:

To begin this Selenium test, the first thing we are going to do is instantiate a new WebDriver. (00:30) Since we are utilizing Firefox for this test we are going to instantiate the GetkoDriver and complete all of the steps that come along with instantiating that driver.

 

Completing Drag and Drop User Interaction

Next, we are going to navigate to our webpage. To complete the drag and drop action you need a starting and an ending point. So, your next step should be to locate those two elements. (1:05) Selenium provides an actions class with numerous methods for where you can perform a bunch of complex user interactions. For the drag and drop, the actions that you will want to perform are:

  1. Click and hold method
  2. Move to element method

For both of these methods you will need to pass, for the click and hold – the starting point, and for the move to element – the ending point. (1:28) Once you get to that endpoint you will want to release that element and then call the build method. The build method is used to loop all of the sequences together. Then you can utilize the “perform” method to perform the entire action. This method is often utilized to complete Selenium composite actions for linear scripts.

 

Creating an Action Method

If you wanted to pull the previous action out and create an action method you would need to pass the starting and ending element to that method as well as the Driver. Then,

  1. Create a new instance of the actions class
  2. Create an object of the actions class that would contain all these steps

(2:07) Last, you will want to “call” all these steps again. At this point you can call that action objects at any point and time later on in our test.

We hope this helps you complete complex user interactions using complex actions provided by Selenium. Contact us at contact@zenergytechnologies.com with any questions.

>> Subscribe to Zenergy on Youtube for more videos

 

Are you making BIG mistakes in your Selenium implementations?

Read our blog, Five Common Missteps in Selenium Test Automation Implementations.