How to Get the Tooltip text through Selenium Webdriver


Webdriver script to get Tooltip text in selenium webdriver.

package selenium_examples;


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

public class Sample {

public static void main(String[] args)
   {

WebDriver driver = new FirefoxDriver();
   driver.get("http://docs.seleniumhq.org/");
   WebElement toolTipObject = driver.findElement(By.xpath("/html/body/div/div/h1/a"));
   String GoogleTooltip = toolTipObject.getAttribute("title");
        System.out.println(GoogleTooltip);
             }

           }

Output of the script:-

Return to Selenium home page


Above script opens http://docs.seleniumhq.org/ webpage and gets the tooltip of below highlighted part. imag



getAttribute():-Gets the value of an element attribute specified.


No comments:

Related Posts Plugin for WordPress, Blogger...

Fun and Knowledge