Use Actions.doubleClick() to simulate a double-click event.
Basic double click:
Java
WebElement element = driver.findElement(By.id("editableField"));
Actions actions = new Actions(driver);
actions.doubleClick(element).perform();
Double click then verify:
Java
WebElement label = driver.findElement(By.id("editableLabel"));
Actions actions = new Actions(driver);
actions.doubleClick(label).perform();
WebElement input = driver.findElement(By.cssSelector("#editableLabel input"));
input.sendKeys("new text");
Common use cases:
- ✓Double-click to edit inline table cells
- ✓Double-click to open files in a file manager component
- ✓Double-click to select a word in a text editor
Note:
doubleClick(element)is equivalent tomoveToElement(element).doubleClick()— both achieve the same result.
