Nick
Nick

Reputation: 1

How do i Extract tooltip content using selenium where tooltip is dynamically loading by javascript?

I am testing a web-application where i need to verify the contents of a tooltip that is displayed on moving my mouse over a part of the graphics.

Here is the section of html code where this tip is coming from:

<div id="area-serverSlot-6a" class="annotation" style="width: 21px; height: 38px; left: 186px; top: 117px; position: absolute; z-index: 20; cursor: pointer;" name="annotation" present="1" tooltip="" href="javascript:select_module('server', '6a');" onareaover="javascript:DisplayTip('serverSlot-6a', TITLE,'Server Slot 6a')" onareaout="javascript:UnTip()"></div>

I am not able to move my mouse on top of the tooltip as it moves with the mouse. Please suggest some way to get the contents of the tooltip.

Here is the code for DisplayTip:

function DisplayTip()
{
var titleType = arguments[2];
var slotNumPos = titleType.lastIndexOf(' ');
var slotNum = " UNKNOWN";
var title = "UNKNOWN";
if (titleType.indexOf('Server') >= 0) title = vServerSlot;
else if (titleType.indexOf('IOM') >= 0) title = vIOMSlot;
else if (titleType.indexOf('PSU') >= 0) title = vPSUSlot;
else if (titleType.indexOf('CMC') >= 0) title = vCMCSlot;
else  if (titleType.indexOf('KVM') >= 0) title = vKVMSlot;
else if (titleType.indexOf('Fan') >= 0) title = vFanSlot;
else if (titleType.indexOf('LCD') >= 0) title = vLcdSlot;
if (slotNumPos >= 0)
{
slotNum = titleType.substring(slotNumPos);
title += slotNum;
}
TagToTip(arguments[0], TITLE, title, JUMPHORZ, true,
JUMPVERT, true, ABOVE, true);
} 

Upvotes: 0

Views: 2221

Answers (1)

Kapil
Kapil

Reputation: 1810

Nick,

I have taken an example of Linkedin.

 WebDriver driver = new InternetExplorerDriver();
    driver.get("http://www.linkedin.com/");
    WebElement onElement = driver.findElement(By.xpath("html/body/div[1]/div[1]/div/h2/a"));
    System.out.println("Tooltip : " + onElement.getAttribute("title"));

Upvotes: 1

Related Questions