Sunday, 14 May 2017

Gmail application

GMAIL APPLICATION:USING SELINIUM TOOL(AUTOMATION)

SCENARIO:

Login to gmail application capture number of unread message available in inbox table.



program:

package practice;

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

public class Gmail {

public static void main(String[] args) throws InterruptedException 
       {
FirefoxDriver driver=new FirefoxDriver();

driver.manage().window().maximize();

driver.get("https://gmail.com");

driver.findElement(By.id("identifierId")).sendKeys("abc@123@gmail.com");

driver.findElement(By.xpath("//span[text()='Next']")).click();
           
Thread.sleep(4000);

driver.findElement(By.name("password")).sendKeys("******");

driver.findElement(By.xpath("//span[text()='Next']")).click();

Thread.sleep(25000);

String actmsg=driver.findElement(By.xpath("//a[contains(text(),'Inbox')]")).getText();

System.out.println(actmsg.substring(7, actmsg.length()-1));
driver.findElement(By.xpath("//span[@class='gb_9a gbii']")).click();

driver.findElement(By.xpath("//a[text()='Sign out']")).click();

driver.quit();


}

}

Note:
1. driver.findElement(By.id("identifierId")).sendKeys("abc@123@gmail.com");..(example) we have to give your own mail id

2.driver.findElement(By.name("password")).sendKeys("*****");....(example)
we have to give your own password

Share:

2 comments:

  1. package selinium;

    public class testcase1 {

    public static void main(String[] args) {
    FirefoxDriver driver=new FirefoxDriver();
    (This line is error like "create one class for FirefoxDriver")
    driver.get("http://localhost/login.do");

    }

    }
    how to solve this?

    ReplyDelete
  2. keep courser on that error word then some options will come we have to click on import statement.....or ctrl+shift+o

    ReplyDelete

Testersonly. Powered by Blogger.