How to identify the tool-tip

93 views
Skip to first unread message

Suresh Kumar

unread,
Apr 21, 2014, 1:42:27 AM4/21/14
to seleniu...@googlegroups.com
How to identify the too-tip and print the text present in that tool-tip.
The codes below which i used,but its not working.
Any suggestions...


==============================================================================      
            JavascriptExecutor js = (JavascriptExecutor) driver;
            String  UsernameTooltip = (String)js.executeScript("return validationMessages['id-12345-tooltip']");
            Assert.assertEquals("A Unit associated with active Users cannot be deleted",UsernameTooltip);
            System.out.println("Username tooltip verified successfully");*/
==============================================================================               
            WebElement element=driver.findElement(By.id("id-12345"));
            Actions builder = new Actions(driver);  // Here we use Action for interaction 
            Action mouseOver =builder.moveToElement(element).build(); // Build action for element  
            mouseOver.perform(); // perform action on element
            TimeUnit.SECONDS.sleep(10);
            String Tooltip = element.getAttribute("id-12345-tooltip");
            System.out.println(Tooltip);
              if(mouseOver.equals("A Unit associated with active Users cannot be deleted"))
              {
               System.out.println("Tool tip text is: ");
              }else{
               System.out.println("No Tool tip text present");
              }  

Dhiraj

unread,
Apr 21, 2014, 2:15:55 AM4/21/14
to seleniu...@googlegroups.com
Hi Suresh,

Use the getAttribute method..
getAttribute("title") or getAttribute("alt")
Thanks,
Dhiraj

DongXiang

unread,
Apr 21, 2014, 3:13:33 AM4/21/14
to seleniu...@googlegroups.com
I guess it should use 
String Tooltip = element.getAttribute("title"); 
to replace String 
Tooltip = element.getAttribute("id-12345-tooltip");

id-12345-tooltip is not an attribute for your web element.

Best Regards,
--david


Date: Sun, 20 Apr 2014 22:42:27 -0700
From: suri...@gmail.com
To: seleniu...@googlegroups.com
Subject: [selenium-users] How to identify the tool-tip
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.
To post to this group, send email to seleniu...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/da3ae4ec-0cff-44ff-a2d9-893106410e40%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Suresh Kumar

unread,
Apr 21, 2014, 5:42:10 AM4/21/14
to seleniu...@googlegroups.com, DongXiang, Dhiraj
Hi

Thanks for your suggestions

getAttribute("title") or getAttribute("alt") also not capture the tool-tip.
The case is:
The tool-tip is displayed, when only mouse-over on the icon.
so i want to read and print the too-tip text that time.


--
You received this message because you are subscribed to a topic in the Google Groups "Selenium Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/selenium-users/d4Jwgcw_mkA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.

murali

unread,
Apr 21, 2014, 10:18:50 AM4/21/14
to seleniu...@googlegroups.com
Hi Suresh,

let me know is your tool tip message is displaying as text or as attribute in back-end HTML?

generally i will search for tool tip text in HTML page so that i can able to know as it is coded as text or any attribute. 

if it is text i will use getText after mouse move (may be for time delay need to get that tool tip message) or else get that attribute..

Thanks,
Murali

Kaustubh Joshi

unread,
Apr 22, 2014, 12:30:38 AM4/22/14
to seleniu...@googlegroups.com
Suresh,

You need to make of Actions class, Action interface given in selenium Java docs where you'll get methods which would do the job for you...

Cheers,
K


--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to selenium-user...@googlegroups.com.

To post to this group, send email to seleniu...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages