Saturday, June 14, 2014

Use of getAttribute() method.

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();
    }
}

No comments:

Post a Comment