Tooltip displayed for an element is identifed based on the attribute title defined for the element. Knowing that title of the element is the tooltip resolves half of the problem.
Suppose there is an element with id as abcde, the tooltip of the element can be stored in a string using code as below:
//example 1: getting tooltip of the elemet String strToolTipText = driver.findElement(By.xpath("//input[@id='abcde']").getAttribute("title"); //example 2 : Validating tooltip is displayed correctly for an webElement
public boolean verifyTooltipText(WebElement webElem, String expToolTiptext) { String acttooltiptext = webElem.getAttribute("title"); if(acttooltiptext.contentEquals(exptooltiptext)) { return true } else { return false } }
No comments:
Post a Comment