How to Login gmail and find the online status who are AVAILABLE, IDLE and INVISIBLE and print in console?

package TechLearndotin;
import java.io.IOException;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class GmailOnlinePeople {
static WebDriver driver;
public static void main(String[] args) throws IOException{

driver =new  FirefoxDriver();
driver.get("https://accounts.google.com/ServiceLogin?sacu=1&scc=1&continue=https%3A%...");
driver.findElement(By.id("Email")).sendKeys("techlearn.inmails@gmail.com"); // ENTER YOUR GMAIL ID
driver.findElement(By.id("Passwd")).sendKeys("techlearn.in"); // ENTER YOUR GMAIL PASSWORD
driver.manage().window().maximize();
driver.findElement(By.id("signIn")).click();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
//Green: Available. You are online and ready to chat.
try{  
List<WebElement>Available =driver.findElements(By.xpath("//tr[td[img[@alt='Available']]]/td[2]/span[1]"));
if(Available.size()!=0){
System.out.println("======*********AVALIBLE STATUS***********======");
for(int i=0;i<Available.size();i++){
String Names =Available.get(i).getAttribute("textContent");
System.out.println((i+1)+")" +Names);
}}}
catch(NoSuchElementException NSE){
System.out.println("No Friends Are Avalible in Status");
}
//Yellow: Idle.Your status automatically changes to idle when you're away 4m ur computer for 15 minutes.You can't manually select to appear idle
try{
List<WebElement>Idle =driver.findElements(By.xpath("//tr[td[img[@alt='Idle']]]/td[2]/span[1]"));
driver.manage().timeouts().implicitlyWait(1, TimeUnit.MINUTES);
if(Idle.size()!=0){
System.out.println("=======**********IDLE STATUS *************======");
for(int i=0;i<Idle.size();i++){
String Name=Idle.get(i).getAttribute("textContent");
System.out.println((i+1)+") "+Name);
}}}
catch (NoSuchElementException NSE) {
System.out.println("No Friend in Idel Status");
}
//Grey:Signed out of chat, or Invisible. If U set ur status to Invisible, you'll appear to be signed out of chat even when you're actually signed in
try{
List<WebElement>Offline=driver.findElements(By.xpath("//tr[td[img[@alt='Offline']]]/td[2]/span[1]"));
if(Offline.size()!=0){
System.out.println("=====*********INVISIBLE STATUS"        + ""         + "********======");
for(int i=0;i<Offline.size();i++){
String Names=Offline.get(i).getAttribute("textContent");
System.out.println((i+1)+")" + Names);
}} }
catch(NoSuchElementException NSE){
System.out.println("No Friends Are offline in Status");
}
finally{
driver.findElement(By.xpath("//span[@class='gb_X gbii']")).click();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.findElement(By.id("gb_71")).click();
}}}

Tags: