How To Get Tooltip Text In Selenium WebDriver | Software Testing Material

How To Get Tooltip Text In Selenium:

Tooltip Text is a message that appears when we mouse hover on an element. Tooltip is also known as infotip or hit.

When an user mouse hover on an element then a tool tip may appear. Sometimes we need to handle the tooltip text while we are doing automation. Here in this post, we will see how to handle tooltip in Selenium WebDriver.

I use Selenium Actions Class to handle this.

Must Read: Mouse Hover Actions in Selenium

Create object of an Actions Class by passing the WebDriver instance. With the object of the Actions class, driver moves to the required element.

Let’s see a practical example on how to get Tool Tip Text in Selenium WebDriver:

Given clear explanation in the comments section within the program itself. Please go through it to understand the flow.

Execute the above script and see the console output.

Also we could handle tooltip using getAttribute method. Sometimes we could see title attribute related to tooltip while identifying elements and in those cases, we could handle using getAttribute() method.

If you are not a regular reader of my blog then I highly recommend you to signup for the free email newsletter using the below link.

Get our latest blog posts delivered to your inbox

Subscribe and get popular blog posts about software testing industry.

Rajkumar

Leave a Comment

Share via
Copy link
Powered by Social Snap