Double Click in Selenium WebDriver
Double Click is a common mouse interaction used in web applications to perform an action when a user clicks an element twice in quick succession. In Selenium WebDriver, double-click operations can be automated using the Actions class.
Double-click automation is useful when testing buttons, files, table rows, images, menus, links, editable fields, custom controls, and other web elements that respond to two consecutive mouse clicks.
Selenium Training Course | Register for Course Demo
1. What is Double Click?
A double click is a mouse action in which the user clicks the same element twice within a short interval. Web applications can use this interaction to trigger specific functionality such as opening an item, editing a record, selecting a row, expanding content, or displaying additional information.
In Selenium Java, the Actions class provides the doubleClick() method for automating this interaction.
2. Why is Double Click Important in Selenium?
Modern web applications frequently use mouse-based interactions. A normal click() may not be sufficient when an application specifically expects two clicks.
- Automates real-world user interactions.
- Tests controls that require two clicks.
- Validates custom UI behavior.
- Supports interactive table testing.
- Helps automate editable records.
- Can be used with menus and expandable components.
- Improves coverage of mouse-based functionality.
3. Double Click in Selenium WebDriver
Selenium WebDriver provides the Actions class to perform advanced mouse and keyboard operations. The doubleClick() method can be used to perform a double-click on an element.
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
4. Actions Class
The Actions class is part of Selenium's interaction API. It is commonly used for advanced user interactions such as mouse movement, double click, right click, drag and drop, click and hold, keyboard combinations, and other composite actions.
Actions actions = new Actions(driver);
5. Basic Double Click Syntax
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
Here:
actions is the Actions object.
doubleClick(element) performs a double click on the specified element.
perform() executes the built action.
6. Import Required Classes
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
7. Simple Double Click Example
WebDriver driver = new ChromeDriver();
driver.get("https://example.com");
WebElement element = driver.findElement(By.id("doubleClickButton"));
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
8. Double Click Using ID Locator
If the target element has a unique ID, the ID locator can be used.
WebElement button = driver.findElement(By.id("doubleClickButton"));
Actions actions = new Actions(driver);
actions.doubleClick(button).perform();
9. Double Click Using Name Locator
WebElement element = driver.findElement(By.name("editRecord"));
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
10. Double Click Using Class Name
WebElement element = driver.findElement(By.className("editable-row"));
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
11. Double Click Using CSS Selector
WebElement element = driver.findElement(By.cssSelector("#doubleClickButton"));
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
12. Double Click Using XPath
WebElement element = driver.findElement(
By.xpath("//button[@id='doubleClickButton']")
);
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
13. Double Click on a Button
WebElement button = driver.findElement(By.xpath("//button[text()='Open']"));
Actions actions = new Actions(driver);
actions.doubleClick(button).perform();
This can be useful when the application opens a detailed view only after a double click.
14. Double Click on a Table Row
WebElement row = driver.findElement(
By.xpath("//table[@id='users']//tr[2]")
);
Actions actions = new Actions(driver);
actions.doubleClick(row).perform();
15. Double Click on an Image
WebElement image = driver.findElement(
By.cssSelector("img.product-image")
);
Actions actions = new Actions(driver);
actions.doubleClick(image).perform();
16. Double Click on a Link
WebElement link = driver.findElement(
By.linkText("Open Details")
);
Actions actions = new Actions(driver);
actions.doubleClick(link).perform();
17. Double Click on a WebElement
The recommended approach is to locate the target element first and then pass it to doubleClick().
WebElement target = driver.findElement(By.id("target"));
Actions actions = new Actions(driver);
actions.doubleClick(target).perform();
18. Double Click Without Specifying an Element
The Actions API also provides doubleClick() without an element. This performs the double click at the current mouse location.
Actions actions = new Actions(driver);
actions.doubleClick().perform();
When possible, explicitly identifying the target element is generally clearer and more reliable.
19. Move to Element and Double Click
Sometimes the target needs to be brought into the pointer location before the double click.
WebElement element = driver.findElement(By.id("target"));
Actions actions = new Actions(driver);
actions.moveToElement(element)
.doubleClick()
.perform();
20. Difference Between click() and doubleClick()
| Feature | click() | doubleClick() |
| Number of clicks | One | Two |
| API | WebElement / Actions | Actions |
| Typical use | Buttons and links | Editable rows and special controls |
| Method | click() | doubleClick() |
| Mouse interaction | Single click | Two consecutive clicks |
21. WebElement click() vs Actions doubleClick()
The WebElement click() method performs a single click. For a true double-click interaction, the Actions API should be used.
element.click();
For double click:
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
22. Complete Double Click Program
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
public class DoubleClickExample {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("https://example.com");
WebElement element = driver.findElement(
By.id("doubleClickButton")
);
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
driver.quit();
}
}
23. Double Click with Explicit Wait
Dynamic applications may require the target element to become visible or clickable before performing the double click.
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
WebElement element = wait.until(
ExpectedConditions.elementToBeClickable(By.id("doubleClickButton"))
);
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
24. Required Explicit Wait Imports
import java.time.Duration;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
25. Why Explicit Wait is Useful?
- Handles dynamically loaded elements.
- Reduces timing-related failures.
- Waits for the required application state.
- Improves test stability.
- Reduces unnecessary hard-coded delays.
26. Avoid Hard-Coded Sleep
Using Thread.sleep() may make tests slower and less reliable.
Thread.sleep(3000);
actions.doubleClick(element).perform();
A condition-based explicit wait is generally preferable when synchronization is required.
27. Double Click on Dynamic Elements
Dynamic web applications may create or update elements after page loading. In such cases, locate the element after the relevant state is available.
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));
WebElement row = wait.until(
ExpectedConditions.visibilityOfElementLocated(
By.cssSelector(".dynamic-row")
)
);
Actions actions = new Actions(driver);
actions.doubleClick(row).perform();
28. Double Click on Editable Table Row
Some business applications allow users to edit a record by double-clicking its row.
WebElement row = driver.findElement(
By.xpath("//table[@id='employeeTable']//tr[2]")
);
new Actions(driver).doubleClick(row).perform();
29. Double Click to Open Record
WebElement record = driver.findElement(
By.xpath("//div[@class='record'][1]")
);
new Actions(driver).doubleClick(record).perform();
30. Double Click to Edit a Record
WebElement customer = driver.findElement(
By.xpath("//tr[contains(@class,'customer-row')]")
);
Actions actions = new Actions(driver);
actions.doubleClick(customer).perform();
31. Double Click and Verify Result
After performing a double click, the expected result should be validated.
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
WebElement editForm = driver.findElement(By.id("editForm"));
if (editForm.isDisplayed()) {
System.out.println("Double click action successful");
}
32. Double Click with TestNG Assertion
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
WebElement editForm = driver.findElement(By.id("editForm"));
Assert.assertTrue(
editForm.isDisplayed(),
"Edit form was not displayed after double click"
);
33. TestNG Double Click Test
@Test
public void verifyDoubleClick() {
WebElement element = driver.findElement(
By.id("doubleClickButton")
);
new Actions(driver)
.doubleClick(element)
.perform();
Assert.assertTrue(
driver.findElement(By.id("result")).isDisplayed()
);
}
34. Double Click in Page Object Model
In the Page Object Model, the double-click operation can be encapsulated inside the page class.
public void doubleClickRecord() {
WebElement record = driver.findElement(
By.id("record")
);
new Actions(driver)
.doubleClick(record)
.perform();
}
35. Page Object Model Example
public class CustomerPage {
private WebDriver driver;
private By customerRow = By.id("customerRow");
public CustomerPage(WebDriver driver) {
this.driver = driver;
}
public void doubleClickCustomer() {
WebElement element = driver.findElement(customerRow);
new Actions(driver)
.doubleClick(element)
.perform();
}
}
36. Calling Double Click from Test Class
@Test
public void editCustomer() {
CustomerPage customerPage =
new CustomerPage(driver);
customerPage.doubleClickCustomer();
}
37. Reusable Double Click Utility
public class ActionUtils {
private WebDriver driver;
public ActionUtils(WebDriver driver) {
this.driver = driver;
}
public void doubleClick(WebElement element) {
new Actions(driver)
.doubleClick(element)
.perform();
}
}
38. Using the Double Click Utility
ActionUtils actions = new ActionUtils(driver);
WebElement element = driver.findElement(
By.id("record")
);
actions.doubleClick(element);
39. Double Click and Move to Element
WebElement element = driver.findElement(By.id("target"));
new Actions(driver)
.moveToElement(element)
.doubleClick()
.perform();
40. Double Click on a Specific Coordinate
Coordinate-based interaction should generally be avoided when a stable element locator is available. Element-based automation is more maintainable.
For complex interfaces, the preferred approach is to locate the element and use the Actions API.
41. Double Click on Nested Elements
When an element contains child elements, choose the locator carefully so that the interaction occurs on the intended target.
WebElement item = driver.findElement(
By.cssSelector(".menu-item .item-title")
);
new Actions(driver)
.doubleClick(item)
.perform();
42. Double Click on Text
Some applications use double click on text to activate editing or selection.
WebElement text = driver.findElement(
By.xpath("//span[text()='Customer Name']")
);
new Actions(driver)
.doubleClick(text)
.perform();
43. Double Click on a Div Element
WebElement card = driver.findElement(
By.cssSelector("div.customer-card")
);
new Actions(driver)
.doubleClick(card)
.perform();
44. Double Click on a Checkbox Container
Some custom UI components attach behavior to a container rather than the native checkbox.
WebElement container = driver.findElement(
By.cssSelector(".custom-checkbox")
);
new Actions(driver)
.doubleClick(container)
.perform();
45. Double Click on Custom UI Controls
Modern web applications often use custom controls built using HTML, CSS and JavaScript. Selenium can interact with them when they are accessible as DOM elements.
WebElement control = driver.findElement(
By.cssSelector(".custom-control")
);
new Actions(driver)
.doubleClick(control)
.perform();
46. Double Click on JavaScript-Based Elements
If JavaScript listens for a double-click event such as dblclick, Selenium's Actions API can trigger the browser interaction.
WebElement canvasItem = driver.findElement(
By.id("canvasItem")
);
new Actions(driver)
.doubleClick(canvasItem)
.perform();
47. Double Click Event in HTML
A web page can define a JavaScript double-click event.
<button id="openButton">
Double Click Me
</button>
<script>
document.getElementById("openButton")
.addEventListener("dblclick", function() {
alert("Double click detected");
});
</script>
48. Automating a Double Click JavaScript Event
WebElement button = driver.findElement(
By.id("openButton")
);
new Actions(driver)
.doubleClick(button)
.perform();
Alert alert = driver.switchTo().alert();
System.out.println(alert.getText());
alert.accept();
49. Double Click Followed by Alert Handling
new Actions(driver)
.doubleClick(element)
.perform();
WebDriverWait wait = new WebDriverWait(
driver,
Duration.ofSeconds(10)
);
Alert alert = wait.until(
ExpectedConditions.alertIsPresent()
);
System.out.println(alert.getText());
alert.accept();
50. Double Click Followed by Page Navigation
new Actions(driver)
.doubleClick(element)
.perform();
WebDriverWait wait = new WebDriverWait(
driver,
Duration.ofSeconds(10)
);
wait.until(ExpectedConditions.urlContains("details"));
System.out.println(driver.getCurrentUrl());
51. Double Click and Verify URL
new Actions(driver)
.doubleClick(element)
.perform();
Assert.assertTrue(
driver.getCurrentUrl().contains("details"),
"Expected details page was not opened"
);
52. Double Click and Verify Text
new Actions(driver)
.doubleClick(element)
.perform();
WebElement message = driver.findElement(
By.id("successMessage")
);
Assert.assertEquals(
message.getText(),
"Record opened"
);
53. Double Click and Verify Visibility
new Actions(driver)
.doubleClick(element)
.perform();
WebElement panel = new WebDriverWait(
driver,
Duration.ofSeconds(10)
).until(
ExpectedConditions.visibilityOfElementLocated(
By.id("detailsPanel")
)
);
Assert.assertTrue(panel.isDisplayed());
54. Double Click with Scrolling
If an element is outside the visible viewport, scrolling can help bring it into view before interaction.
WebElement element = driver.findElement(
By.id("target")
);
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView({block:'center'});",
element
);
new Actions(driver)
.doubleClick(element)
.perform();
55. Required JavaScript Executor Import
import org.openqa.selenium.JavascriptExecutor;
56. Double Click Inside an iframe
If the target element exists inside an iframe, Selenium must switch into the iframe before locating and interacting with the element.
WebElement frame = driver.findElement(
By.id("paymentFrame")
);
driver.switchTo().frame(frame);
WebElement element = driver.findElement(
By.id("doubleClickButton")
);
new Actions(driver)
.doubleClick(element)
.perform();
driver.switchTo().defaultContent();
57. Double Click in Nested Frames
driver.switchTo().frame("outerFrame");
driver.switchTo().frame("innerFrame");
WebElement element = driver.findElement(
By.id("target")
);
new Actions(driver)
.doubleClick(element)
.perform();
driver.switchTo().defaultContent();
58. Double Click in a New Window
If a double click causes another browser window or tab to open, switch to the appropriate window handle before continuing with further validation.
String parent = driver.getWindowHandle();
new Actions(driver)
.doubleClick(element)
.perform();
for (String handle : driver.getWindowHandles()) {
if (!handle.equals(parent)) {
driver.switchTo().window(handle);
break;
}
}
59. Double Click and Multiple Windows
String parentWindow = driver.getWindowHandle();
new Actions(driver)
.doubleClick(element)
.perform();
for (String handle : driver.getWindowHandles()) {
if (!handle.equals(parentWindow)) {
driver.switchTo().window(handle);
System.out.println(
driver.getTitle()
);
}
}
60. Double Click Exception Handling
Automation frameworks should handle expected Selenium exceptions appropriately and provide useful logs.
try {
WebElement element = driver.findElement(
By.id("target")
);
new Actions(driver)
.doubleClick(element)
.perform();
} catch (Exception e) {
System.out.println(
"Double click failed: " + e.getMessage()
);
}
61. ElementNotInteractableException
This exception can occur when the element cannot currently be interacted with.
Possible reasons include:
- Element is hidden.
- Element is disabled.
- Another element is covering it.
- Application state is not ready.
62. ElementClickInterceptedException
An overlay, popup, tooltip, or another element may intercept the interaction.
Useful troubleshooting steps include:
- Wait for overlays to disappear.
- Scroll the element into view.
- Check the element's visibility.
- Use a more stable locator.
- Wait for the required application state.
63. StaleElementReferenceException
A stale element exception can occur when the DOM changes after the element was located.
A common solution is to locate the element again after the DOM update.
WebElement element = wait.until(
ExpectedConditions.refreshed(
ExpectedConditions.elementToBeClickable(
By.id("target")
)
)
);
new Actions(driver)
.doubleClick(element)
.perform();
64. Element Not Visible Problem
If an element is not visible, check:
- Whether the correct locator is used.
- Whether the element is displayed.
- Whether a parent component is collapsed.
- Whether an iframe switch is required.
- Whether an overlay is covering the element.
65. Double Click on Hidden Elements
A hidden element should not normally be treated as an ordinary user-interaction target. Instead, make the required UI state visible and interact with the actual visible element.
66. Double Click on Disabled Elements
A disabled control may not respond to user interaction. Selenium should verify the application behavior rather than forcing an artificial interaction.
WebElement button = driver.findElement(
By.id("submitButton")
);
Assert.assertFalse(
button.isEnabled(),
"Button should be disabled"
);
67. Double Click with Stable Locators
Stable locators make double-click tests more reliable.
- Prefer unique IDs.
- Use meaningful data attributes where available.
- Use stable CSS selectors.
- Use relative XPath when appropriate.
- Avoid fragile absolute XPath.
68. Good XPath Example
By.xpath("//button[@id='editButton']")
69. Avoid Fragile XPath
Avoid locators that depend heavily on changing DOM indexes.
//div[3]/div[2]/table/tr[4]/td[2]/button
Prefer a meaningful attribute or relationship-based locator.
70. Double Click Test Scenario
Consider a CRM application containing a customer table. A user double-clicks a customer row to open its edit screen.
- Open the CRM application.
- Login with valid credentials.
- Navigate to the customer list.
- Locate the required customer.
- Double-click the customer row.
- Wait for the edit screen.
- Verify customer information.
- Capture evidence if required.
- Close the browser.
71. CRM Double Click Example
WebElement customerRow = new WebDriverWait(
driver,
Duration.ofSeconds(10)
).until(
ExpectedConditions.elementToBeClickable(
By.xpath("//tr[@data-customer='1001']")
)
);
new Actions(driver)
.doubleClick(customerRow)
.perform();
WebElement editPage = new WebDriverWait(
driver,
Duration.ofSeconds(10)
).until(
ExpectedConditions.visibilityOfElementLocated(
By.id("customerEditForm")
)
);
Assert.assertTrue(editPage.isDisplayed());
72. E-Commerce Double Click Scenario
An e-commerce application may use double click on a product card to open detailed information or an expanded product view.
WebElement product = driver.findElement(
By.cssSelector(".product-card")
);
new Actions(driver)
.doubleClick(product)
.perform();
73. File Manager Double Click Scenario
File-management interfaces commonly use double click to open a file or folder.
WebElement folder = driver.findElement(
By.xpath("//div[@class='folder'][1]")
);
new Actions(driver)
.doubleClick(folder)
.perform();
74. Dashboard Double Click Scenario
A dashboard may allow users to double-click a chart, tile, or record to open detailed information.
WebElement dashboardCard = driver.findElement(
By.id("salesCard")
);
new Actions(driver)
.doubleClick(dashboardCard)
.perform();
75. Sample Test Case
| Test Case ID | Scenario | Expected Result |
| TC_DOUBLECLICK_001 | Double click valid record | Record opens successfully |
| TC_DOUBLECLICK_002 | Double click editable row | Edit mode appears |
| TC_DOUBLECLICK_003 | Double click hidden control | Interaction is prevented appropriately |
| TC_DOUBLECLICK_004 | Double click dynamic element | Element is located after loading and action succeeds |
76. Double Click Test Case Template
Test Case ID: TC_DOUBLECLICK_001
Title: Verify double click functionality
Precondition: User is logged in
Steps:
1. Navigate to the required page
2. Locate the target element
3. Perform double click
4. Wait for expected result
5. Validate the result
Expected Result:
The application should perform the action associated
with the double-click event.
77. Double Click with Screenshot on Failure
try {
WebElement element = driver.findElement(
By.id("target")
);
new Actions(driver)
.doubleClick(element)
.perform();
} catch (Exception e) {
File screenshot = ((TakesScreenshot) driver)
.getScreenshotAs(OutputType.FILE);
System.out.println(
"Double click failed: " + e.getMessage()
);
}
78. Screenshot Imports
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import java.io.File;
79. Logging Double Click Actions
Logging helps identify which element was interacted with and where a failure occurred.
System.out.println(
"Performing double click on customer record"
);
new Actions(driver)
.doubleClick(element)
.perform();
System.out.println(
"Double click completed"
);
80. Double Click in Automation Framework
In a professional framework, double-click logic should be reusable rather than duplicated across every test.
- Page objects should contain page-specific elements.
- Action utilities should contain reusable interactions.
- Wait utilities should contain synchronization logic.
- Test classes should focus on test scenarios.
- Reporting should capture failures.
81. Recommended Framework Structure
src
├── main
│ └── java
│ ├── pages
│ ├── utilities
│ ├── waits
│ └── base
└── test
└── java
├── tests
└── testdata
82. Double Click Utility with Wait
public void doubleClick(By locator) {
WebDriverWait wait =
new WebDriverWait(driver, Duration.ofSeconds(10));
WebElement element = wait.until(
ExpectedConditions.elementToBeClickable(locator)
);
new Actions(driver)
.doubleClick(element)
.perform();
}
83. Using the Utility
doubleClick(By.id("customerRow"));
84. Best Practices for Double Click
- Use the Actions class for double-click interactions.
- Prefer stable element locators.
- Use explicit waits for dynamic applications.
- Verify the result after the interaction.
- Keep action logic reusable.
- Avoid unnecessary hard-coded sleeps.
- Handle iframes correctly.
- Capture screenshots for important failures.
- Keep page-specific locators inside page objects.
- Use meaningful test case names.
85. Common Mistakes
- Using
element.click() when two clicks are required.
- Trying to double-click a hidden element.
- Using unstable XPath expressions.
- Ignoring dynamic loading.
- Not switching into an iframe.
- Ignoring overlays and popups.
- Using unnecessary JavaScript to replace normal user interaction.
- Not validating the result of the double click.
- Duplicating Actions code across many tests.
- Using long hard-coded sleeps.
86. Double Click vs JavaScript Click
| Aspect | Actions Double Click | JavaScript |
| User-like interaction | Yes | Not necessarily |
| Mouse event simulation | Yes | Direct script execution |
| Preferred for normal UI testing | Yes | Usually fallback |
| Maintainability | Generally better | Depends on use case |
87. Why Actions is Preferred?
The Actions API represents advanced user interactions and is appropriate when a test needs to simulate mouse behavior such as double click, drag and drop, hover, click and hold, and keyboard combinations.
88. Double Click and Accessibility
When automating a double-click interaction, testers should also consider whether the functionality has an accessible alternative. Important actions should not rely exclusively on mouse gestures when the application's accessibility requirements provide another interaction mechanism.
89. Double Click on Responsive Applications
Responsive layouts may change element positions and dimensions across viewport sizes. Prefer element-based interaction rather than coordinate-based automation.
WebElement element = driver.findElement(
By.cssSelector(".responsive-card")
);
new Actions(driver)
.doubleClick(element)
.perform();
90. Double Click in Cross-Browser Testing
When executing automation across multiple browsers, verify that the application responds consistently to the double-click interaction.
| Browser | Test |
| Chrome | Double click behavior |
| Firefox | Double click behavior |
| Edge | Double click behavior |
91. Double Click in Parallel Testing
When tests run in parallel, each test should use an isolated driver instance and independent test data wherever required.
92. Double Click and Test Data
For data-driven tests, the target record can be supplied from test data rather than hard-coded values.
String customerId = "CUST1001";
WebElement row = driver.findElement(
By.xpath("//tr[@data-id='" + customerId + "']")
);
new Actions(driver)
.doubleClick(row)
.perform();
93. Data-Driven Double Click Testing
| Customer ID | Expected Action |
| CUST1001 | Open customer |
| CUST1002 | Open customer |
| CUST1003 | Open customer |
94. Interview Question: What is Double Click in Selenium?
Double click is an advanced mouse interaction used to simulate two consecutive clicks on a web element. Selenium Java provides the doubleClick() method through the Actions class.
95. Interview Question: How do You Perform Double Click?
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
96. Interview Question: Which Class is Used for Double Click?
The org.openqa.selenium.interactions.Actions class is commonly used to perform double-click and other advanced user interactions.
97. Interview Question: Difference Between click() and doubleClick()?
click() performs a single mouse click, while doubleClick() performs a double-click interaction through the Actions API.
98. Interview Question: Why Use perform()?
The perform() method executes the interaction sequence built using the Actions API.
new Actions(driver)
.doubleClick(element)
.perform();
99. Quick Revision
- Double click means two consecutive mouse clicks.
- Selenium's Actions class supports double-click interactions.
- Use
doubleClick(element) for a specific target.
- Use
doubleClick() for the current pointer location.
- Call
perform() to execute the action.
- Use explicit waits for dynamic elements.
- Use stable locators.
- Switch into iframes before interacting with their elements.
- Validate the expected result after the action.
- Use reusable utilities in automation frameworks.
100. Double Click Checklist
- Target element identified correctly.
- Stable locator used.
- Element is visible.
- Element is interactable.
- Required iframe handled.
- Required wait implemented.
- Actions object created.
- Double click executed.
- Expected result validated.
- Failure evidence captured where required.
- Test data isolated.
- Reusable framework utility used where appropriate.
101. Practical Mini Project
Project: Customer Management Double Click Automation
Automate a CRM customer-management page where double-clicking a customer row opens an edit form.
- Launch the browser.
- Open the CRM application.
- Login with valid credentials.
- Navigate to the customer page.
- Locate the customer row using a stable locator.
- Wait until the row is clickable.
- Perform a double click using Actions.
- Wait for the edit form.
- Validate the customer information.
- Capture screenshot if the test fails.
- Generate the test report.
- Close the browser.
@Test
public void verifyCustomerDoubleClick() {
WebDriverWait wait =
new WebDriverWait(driver, Duration.ofSeconds(10));
WebElement customerRow = wait.until(
ExpectedConditions.elementToBeClickable(
By.cssSelector("tr[data-customer='1001']")
)
);
new Actions(driver)
.doubleClick(customerRow)
.perform();
WebElement editForm = wait.until(
ExpectedConditions.visibilityOfElementLocated(
By.id("customerEditForm")
)
);
Assert.assertTrue(
editForm.isDisplayed(),
"Customer edit form was not displayed"
);
}
102. Conclusion
Double Click is an important mouse interaction in Selenium WebDriver automation. Selenium Java provides the Actions class and its doubleClick() method to automate interfaces that depend on two consecutive mouse clicks.
A reliable double-click test should use stable locators, appropriate waits, correct frame or window handling, reusable framework utilities, and assertions that verify the expected application behavior.
Double-click automation is especially useful for CRM systems, e-commerce applications, dashboards, file managers, tables, editable records, custom UI controls, and other web applications where double-click events are part of the user workflow.
Recommended Selenium Learning Resources:
Selenium Training Course | Register for Course Demo