Creating custom DoubleClick an…
  • RSS Feed

Last modified on 4/23/2013 11:35 AM by User.

Creating custom DoubleClick and RightClick actions for Selenium (Java and C#)


The out of the box Set action performs a left click on some objects in the Selenium WebDriver integration for Axe. This article shows how to create custom Set.DoubleClick and Set.RightClick actions for both C# and Java.

For this example we will be using the Actions class in Selenium WebDriver:

This has two methods that we wish to use; DoubleClick() and ContextClick(). For Java, note the case of the first letter:  doubleClick() and contextClick()

Adding Using and Import statements

In order to use this class the relevant using statements need to be added to the top of the C# output from Axe. To do this we need to override the _testInit action in our project action map, we can do this by copying the entry from the supplied action map:

 For C# (copied from SeleniumCSharp.ActionMap and amended as shown):

Adding the Line:

using OpenQA.Selenium.Interactions;


For Java (copied from SeleniumJava.ActionMap and amended as shown):

Adding the line:

import org.openqa.selenium.interactions.Actions;

Our scripts will now be generated with the correct namespace references. Next to add a new instance of the class to the top of our script.

Adding a new Object Instance

In order to do this we need to override the _testPrefix action again by copying from the supplied action maps and amending, in this case as seen below:

For C# (copied from SeleniumCSharp.ActionMap and amended as shown):

Adding the Lines:

Actions actionsBuilder = null;


actionsBuilder = new Actions(selenium);


For Java (copied from SeleniumJava.ActionMap and amended as shown):

This is adding the line:

Actions actionsBuilder = new Actions(selenium);

This will ensure there is an instance of the class available for the scripts to use later on in the actions, so lastly to add the custom actions.

Adding the Custom Actions


This is relatively straightforward now we have the actionsBuilder object (an instance of the Actions Class), we can simply call the relevant methods:

For C# (added to the project action map):

Using the template code statements:




For Java:

Using the template code statements:



The Testers now have two new actions they can use in their subtests:




Attached are the Action Maps for the OdinPortal Sample project (v3.5):

CSharp - OdinPortalSeleniumCSharp.ActionMap.xlsx

Java - OdinPortalSeleniumJava.ActionMap.xlsx