hi use this code.
[code:3ktwtuzt]package com.soapuitutorial.propertie;
import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class gmail {
/**
* @param args
* @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
FirefoxDriver driver = new FirefoxDriver();
driver.get("http://www.gmail.com/");
driver.findElement(By.xpath("//*[@id='Email']")).sendKeys("xxxxxxxxxxxx@gmail.com"+Keys.RETURN);
Thread.sleep(2000);
driver.findElement(By.xpath("//*[@id='Passwd']")).sendKeys("xxxxxxxxxx");
driver.findElement(By.xpath("//*[@id='signIn']")).click();
Thread.sleep(20000L);
String inbox=driver.findElement(By.xpath("//*[contains(@title,'Inbox')]")).getText();
String unreadInboxMails=inbox.substring(inbox.indexOf("(")+1,inbox.indexOf(")"));
System.out.println("inbox "+inbox);
System.out.println(unreadInboxMails);
List<WebElement> mailsObj=driver.findElements(By.xpath("//*[@class='zA zE']"));
System.out.println("total no of unread mails are==="+mailsObj.size());
mailsObj.get(0).click();
}
}
[/code:3ktwtuzt]