Careeroza
Drag and Drop Right Click Double Click
Drag and Drop
WebElement item = driver.findElement(By.id("wishlist-item-101"));
WebElement cart = driver.findElement(By.id("cart-drop-zone"));
new Actions(driver).dragAndDrop(item, cart).perform();
// step by step version, useful when the simple one does not work on a page
new Actions(driver).clickAndHold(item).moveToElement(cart).pause(Duration.ofMillis(200)).release().perform();Note: Some HTML5 drag-and-drop pages (using the draggable attribute and drag events) do not react to WebDriver drags. Teams then trigger the drag events with JavaScriptExecutor.
Right Click and Double Click
new Actions(driver).contextClick(driver.findElement(By.id("order-row-1002"))).perform(); // custom context menu
driver.findElement(By.linkText("Download invoice")).click();
new Actions(driver).doubleClick(driver.findElement(By.cssSelector(".product-image"))).perform(); // zoom in
boolean zoomed = driver.findElement(By.cssSelector(".product-image")).getDomAttribute("class").contains("zoomed");
System.out.println("Zoomed: " + zoomed);Example
Output:
Run ImageZoomTest.main()Example output
Zoomed: true