Category:
Selenium WebDriver
Scenario 1: Tooltip is implemented using the ""title"" attribute
WebElement github = driver.findElement(By.xpath("".//*[@class='soc-ico show-round']/a[4]""));
//get the value of the ""title"" attribute of the github icon
String actualTooltip = github.getAttribute(""title"");
Scenario 2: Tooltip is implemented using a jQuery plugin.
String expectedTooltip = ""What's new in 3.2"";
driver.get(baseUrl);
WebElement download = driver.findElement(By.xpath("".//*[@id='download_now']""));
Actions builder = new Actions (driver);
builder.clickAndHold().moveToElement(download);
builder.moveToElement(download).build().perform();
WebElement toolTipElement = driver.findElement(By.xpath("".//*[@class='box']/div/a""));
String actualTooltip = toolTipElement.getText();
System.out.println(""Actual Title of Tool Tip ""+actualTooltip);
if(actualTooltip.equals(expectedTooltip)) {
System.out.println(""Test Case Passed"");
}