How can I handle/verify tooltip in Selenium Webdriver?

0 votes
How can I handle/verify tooltip in Selenium Webdriver?
Jul 4 in Selenium by Amardeep
25 views

1 answer to this question.

0 votes

Hey Amardeep, tooltips are help or info boxes which pops up when you hover mouse on a web element. They are basically used to provide info or help about the specific webelement. You can handle such tooltips by following this code snippet:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class Tool_Tip {

  public static void main(String[] args) {

     System.setProperty("webdriver.gecko.driver", "D:\\geckodriver.exe");

     WebDriver driver = new FirefoxDriver();

     driver.get("https://forums.edureka.co");

     Actions builder = new Actions(driver);

     // find the tooltip xpath
     WebElement arrow_box_tooltip = driver.findElement(By.className("arrow_box"));

     // Mouse hover to that text message
     builder.moveToElement(arrow_box_tooltip).perform();

     // Extract text from tooltip
     String tooltip_msg = arrow_box_tooltip.getText();

     // Print the tooltip message
     System.out.println("Tooltip/ Help message is " + tooltip_msg);
  }
}
answered Jul 5 by Abha
• 27,180 points

Related Questions In Selenium

0 votes
1 answer
0 votes
1 answer

How can I capture Tooltip in Selenium Webdriver?

Hey Diljeet, following test script allows you ...READ MORE

answered Jul 18 in Selenium by Anvi
• 13,960 points
43 views
+2 votes
1 answer

How can we handle authentication popup in Selenium WebDriver using Java

The Alert Method, authenticateUsing() lets us skip ...READ MORE

answered Apr 18, 2018 in Selenium by king_kenny
• 3,650 points
8,490 views
0 votes
1 answer

How can I create a POM test case in Selenium Webdriver?

Hey Akshay, follow these steps to create ...READ MORE

answered May 12 in Selenium by Anvi
• 13,960 points
72 views
0 votes
1 answer

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,110 points
927 views
0 votes
1 answer
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,130 points
1,109 views
0 votes
1 answer

How to use such xpath to find web elements

It's much simpler to use: #MyDiv123 > div.super or ...READ MORE

answered Jun 14, 2018 in Selenium by Samarpit
• 5,130 points
848 views
0 votes
1 answer
0 votes
1 answer