elements / tooltips
Advanced element
Tooltips & Hover States
Hover-activated CSS tooltips, click-toggled JavaScript info bubbles, and standard HTML title attributes.
CSS tooltip (hover)
#tooltip-cssThis tooltip appears on CSS :hover!
- trigger
- #tooltip-trigger-1
- bubble
- #tooltip-bubble-1
- expected
- Bubble has opacity 1 while hover is active; 0 otherwise.
Code snippets
Python (Selenium)
from selenium.webdriver import ActionChains
trigger = driver.find_element(By.ID, "tooltip-trigger-1")
ActionChains(driver).move_to_element(trigger).perform()
bubble = driver.find_element(By.ID, "tooltip-bubble-1")
assert bubble.is_displayed()
assert "CSS :hover" in bubble.textTypeScript (Playwright)
await page.hover('#tooltip-trigger-1');
const bubble = page.locator('#tooltip-bubble-1');
await expect(bubble).toBeVisible();
expect(await bubble.textContent()).toContain('CSS :hover');JS-toggled tooltip (click)
#tooltip-js- trigger
- #tooltip-trigger-2
- bubble
- #tooltip-bubble-js
- expected
- Toggles display block/none on click.
Code snippets
Python (Selenium)
driver.find_element(By.ID, "tooltip-trigger-2").click()
bubble = driver.find_element(By.ID, "tooltip-bubble-js")
assert bubble.is_displayed()
assert "operational" in bubble.textTypeScript (Playwright)
await page.click('#tooltip-trigger-2');
await expect(page.locator('#tooltip-bubble-js')).toBeVisible();
expect(await page.textContent('#tooltip-bubble-js')).toContain('operational');Native title attribute
#tooltip-native- id
- btn-title-tooltip
- attribute
- title
- expected
- Rendered by OS/browser directly — assert via get_attribute('title').
Code snippets
Python (Selenium)
el = driver.find_element(By.ID, "btn-title-tooltip")
assert el.get_attribute("title") == "Standard browser tooltip via title attribute"TypeScript (Playwright)
const title = await page.getAttribute('#btn-title-tooltip', 'title');
expect(title).toBe('Standard browser tooltip via title attribute');