Menu
A menu bar with sub-menus that open on hover, including a third level. Classic Actions chaining practice.
Practice tasks
- Hover over Training and assert the sub-menu becomes visible.
- Hover over Automation and assert the third-level menu opens.
- Click Playwright in the third level and assert the output shows your selection.
- Move the mouse away and assert both sub-menus close.
- Assert that the sub-menu items are not clickable before hovering.
Sample automation code
Actions actions = new Actions(driver);
actions.moveToElement(driver.findElement(By.id("menu-training")))
.moveToElement(driver.findElement(By.id("menu-automation")))
.moveToElement(driver.findElement(By.id("menu-playwright")))
.click()
.perform();
Assert.assertTrue(driver.findElement(By.id("menu-output")).getText().contains("Playwright"));
await page.getByTestId('menu-training').hover();
await page.getByTestId('menu-automation').hover();
await page.getByTestId('menu-playwright').click();
await expect(page.getByTestId('menu-output')).toContainText('Playwright');