JS Testing Academy · QA Demo Site

Tool Tips

Tooltips that only appear while the mouse is over the element – you need Actions.moveToElement or hover().

Hover over this link as well.

Practice tasks

  1. Hover over the button and assert the tooltip appears with the right text.
  2. Move the mouse away and assert the tooltip disappears.
  3. Hover over the text field and assert the tooltip text is different from the button's.
  4. Assert that no tooltip is present in the DOM before you hover.
Sample automation code
Actions actions = new Actions(driver);
actions.moveToElement(driver.findElement(By.id("tooltip-button"))).perform();

WebElement tip = new WebDriverWait(driver, Duration.ofSeconds(5))
    .until(ExpectedConditions.visibilityOfElementLocated(By.id("tooltip")));
Assert.assertEquals(tip.getText(), "You hovered over the button");