1

The test case is to check if the tooltip message shows.

My html code is as:

<td id="pendingBalance" align="right">
<a onmouseover="displayHelpPopup(this,arrHelp[20][0]);" onmouseout="closePopup();" href="#">
<span class="BoldFont">$0.00</span>

When user moves mouse to $0.00 then tooltip shows some text.

Please help me with the solution to check that the tooltip is displaying with the correct message.

3
  • 4
    Possible duplicate of How do I check if a tooltip appears or not?
    – Alexey R.
    Commented Jul 4, 2018 at 9:48
  • above solution not works in my case i checked and solutions are in getAttribute() but in my case getAttribute() is not valid,
    – Naveen
    Commented Jul 4, 2018 at 9:53
  • Don't, use selenium for functional testing, while is can do UI testing, that is not playing to its strength, UI testing is the domain of human testing not automation. Commented Dec 2, 2018 at 12:58

3 Answers 3

0

You have to mouseOver to $0.00. 1) If you need click, perform click and find the tooltip.

Actions actions = new Actions(driver);
   actions.moveToElement(driver
                .findElement(By.xpath("//span[contains(text(),'0.00')]")));
    actions.perform();
    driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    actions.click().build().perform();
    WebElement element=driver.findElement(By.xpath("xpath of your tooltip")));
    element.click();

2) Else directly find the tooltip.

Actions actions = new Actions(driver);
   actions.moveToElement(driver
                .findElement(By.xpath("//span[contains(text(),'0.00')]")));
    actions.perform();
    driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
    WebElement element=driver.findElement(By.xpath("xpath of your tooltip")));
    element.click();
6
  • By these above logic only possible to hit on xpath and in result it shows message but am unable to get the exact tooltip message which shows
    – Naveen
    Commented Jul 4, 2018 at 10:33
  • Can you add the html code of the Tooltip
    – STE
    Commented Jul 5, 2018 at 9:12
  • i already added in my question
    – Naveen
    Commented Jul 5, 2018 at 9:37
  • @Naveen: 1) post the exact tooltip text(you mentioned it as some text). Your html code doesnot show any tooltip text.
    – STE
    Commented Jul 5, 2018 at 10:10
  • its css function call, a onmouseover="displayHelpPopup(this,arrHelp[20][0]);
    – Naveen
    Commented Jul 5, 2018 at 10:48
0

Tooltip is your example is triggered by javascript code. To automate this process you have to move to the element containign the tooltip text and execute its javascript code:

locate the element:

    WebElement link = driver.findElement(By.cssSelector("#pendingBalance > a"));

perform an action that moves to the element:

    Actions action = new Actions(driver);
    action.moveToElement(link).perform();

execute javascript function 'onmouseover':

    JavascriptExecutor js =  (JavascriptExecutor) driver;
    js.executeScript("arguments[0].onmouseover()", link);
0

Try this piece of code:

Actions driver = new Actions(driver)  
driver.moveToElement(driver.findElement(By.xpath("//span[contains(text(),'$0.00')]"))).build().perform();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.