Skip to main content

How to Handle Tooltips using selenium Webdriver.

Handling the tooltips are easy in selenium, we can achieve by using getAttribute("title"). where tooltips value is given in title attribute. 

Do check out below code for implementation:

 

package SeleniumBasics;

import org.openqa.selenium.By;

import org.openqa.selenium.JavascriptExecutor;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.interactions.Actions;


public class Seleniumtooltips {

    public static void main(String[] args) {

System.setProperty("webdriver.chrome.driver", "E:\\eclipseprojects\\seleniumDemo\\server\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

driver.manage().window().maximize();

driver.get("https://www.facebook.com/");

WebElement link1 = driver.findElement(By.linkText("Sign Up"));

JavascriptExecutor scroll = (JavascriptExecutor) driver;

scroll.executeScript("window.scrollBy(0,1000)");

try {

Thread.sleep(1000);

} catch (Exception e) {

// TODO: handle exception

e.printStackTrace();

}

Actions action = new Actions(driver);

action.moveToElement(link1).perform();

String tooltip = link1.getAttribute("title");

System.out.println("verifying the tooltip :" + tooltip);

}

}

 

Watch out Video in YouTube : 





Comments

Popular posts from this blog

Java Program to Swap Two Numbers

In this program, you'll learn two techniques to swap two numbers in Java. The first one uses a temporary variable for swapping, while the second one doesn't use any temporary variables. To understand this example, you should have knowledge of the following Java programming topics: Basics of Java  Java Operators  Java Data types  Program with Temp Variable : The output of the program is : before swapping value of a:5 value of b:10 after swapping value of a:10 value of b:5 Program without temp variable :  the output of the above program will be: before swapping value of first:5 value of second:10 after swapping value of first:10 value of second:5 Follow my session on youtube : 

Selenium introduction

Selenium introduction and its components: Selenium was created by Jason Huggins in 2004. An engineer at ThoughtWorks, he was working on a web application that required frequent testing. First tool was named as “JavaScriptTestRunner” later named as “Selenium Core” Selenium is a functional automation tool for web applications Selenium is an open-source Selenium can support multiple languages like HTML, java, python, ruby, Perl, PHP and C# Can support multiple browsers like IE, Google Chrome, Mozilla Firefox, Safari and Opera Supports the Operating systems like Windows, Linux, and Mac. Selenium is mainly built-in 4 Components Selenium IDE (Integrated Development Environment) Selenium RC (Remote Control) Selenium WebDriver Selenium Grid Selenium IDE (Integrated Development Environment): Selenium IDE is a simple record and playback tool which comes as an add-on for Mozilla Firefox only. Test cases written in IDE can b...

How to Write Test Cases in Manual Testing

Test Cases document: Test cases play important role during the application testing in software testing. Where each requirement is break down into multiple test scenarios and then after test cases.  here is the test case template, which is being followed by current software testing domain.  High level information:  Test Cases Break down based in the requirement.  For detail Explanation: refer the below video