How can I handle/verify tooltip in Selenium Webdriver?

0 votes
How can I handle/verify tooltip in Selenium Webdriver?
Jul 4, 2019 in Selenium by Amardeep
65 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, 2019 by Abha
• 27,920 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, 2019 in Selenium by Anvi
• 14,030 points
433 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,710 points
14,326 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, 2019 in Selenium by Anvi
• 14,030 points
249 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,510 points
2,547 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,870 points
2,026 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,870 points
2,112 views
0 votes
1 answer

How can I add Cucumber Jar files in Eclipse to use with Selenium Webdriver?

Hey Eshan, follow these steps to add ...READ MORE

answered May 22, 2019 in Selenium by Abha
• 27,920 points
960 views
0 votes
1 answer