Showing posts with label getAttribute in Java Selenium. Show all posts
Showing posts with label getAttribute in Java Selenium. Show all posts

Sunday, 28 June 2015

Selenium WebDriver in Java to fetch attributes from web page

This program is used to get the attributes from Google website.

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

public class Google {
    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.get("https://www.google.co.in/");
        String title = driver.findElement(By.xpath("//div[@id='hplogo']/a/img")).getAttribute("title");
        System.out.println(title);
        driver.close();
    }
}
The execution of the above program will look like as follows:
TODO