Real World Example

Swiggy-style Menu Interactions

Food delivery web apps use hover cards, sticky menus and long scrolling lists of dishes. A regression test for "add a dish from deep in the menu" combines scrolling, hovering and clicking:

driver.get("https://shopease.example.com/c/grocery");
Actions actions = new Actions(driver);
WebElement dairy = driver.findElement(By.xpath("//h2[text()='Dairy and Eggs']"));
actions.scrollToElement(dairy).perform();

WebElement milk = driver.findElement(By.xpath("//h3[text()='Toned Milk 1 L']/ancestor::div[@class='product-card']"));
actions.moveToElement(milk).perform();                          // shows the quick "Add" button on hover
wait.until(ExpectedConditions.elementToBeClickable(milk.findElement(By.cssSelector(".quick-add")))).click();
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.id("cart-count"), "1"));
System.out.println("Cart: " + driver.findElement(By.id("cart-count")).getText());

Example

Output:

Run QuickAddTest.main()

Example output

Cart: 1

Takeaway

Use normal click() and sendKeys() first. Reach for Actions only when the user really hovers, drags or uses key combinations.