1

test case is to show the tooltip message

my html code is below

<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 provide the solution

  • 4
    Possible duplicate of How do I check if a tooltip appears or not? – Alexey R. Jul 4 '18 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 Jul 4 '18 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. – Martin Spamer Dec 2 '18 at 12:58
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();
  • 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 Jul 4 '18 at 10:33
  • Can you add the html code of the Tooltip – STE Jul 5 '18 at 9:12
  • i already added in my question – Naveen Jul 5 '18 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 Jul 5 '18 at 10:10
  • its css function call, a onmouseover="displayHelpPopup(this,arrHelp[20][0]); – Naveen Jul 5 '18 at 10:48
0

Try this below code.

Actions driver = new Actions(driver)  
driver.moveToElement(driver.findElement(By.xpath("//span[contains(text(),'$0.00')]"))).build().perform();
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);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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