Double Click Element using Selenium WebDriver

Let’s see, How can you double Click element using Selenium Webdriver. In this tutorial, we will explain how to work with Actions Class for double clicking an element by taking a simple example. We have already seen, we need to use Actions class in Selenium WebDriver to work on Mouse and Keyboard Actions.


The Actions class provided by Selenium Webdriver is used to generate complex user gestures including right click, double click, drag, and drop etc.


Double Click an Element using Selenium Example

In the given example, We are double clicking an Element. Let’s understand the scenario –

  1. Launch the Web Browser and Navigate to the URL.
  2. Find the required element and do double click on the element.
  3. Accept the Alert(Element Double click will generate the Alert for confirmation)
  4. Close the browser to end the program


Given clear explanation in the comments section with in the program itself. Please go through it to understand the flow.


In the above example, First, we have initialized the Browser and opened the Application inside the @BeforeMethod annotation. And inside the @AfterMethod annotation, we are closing the Browser. If you are confused with the terminology of @BeforeMethod and @AfterMethod than go through the Tutorial, Annotations in TestNG.


Inside the @Test annotation, we have created the webElement of the element on which we want to perform Double Click. Then created the object of Actions class and moved to the element using moveToElement() method of Selenium and performed the doubleClick(). IN application as per functionality it will generate the Alert, So to handle the alert we switched to the Alert and then Accepted it.


That is all, You need to do, to perform the deouble click on Element in Selenium.

0 Comment

Leave a Reply