Here some of them you need to replace:like package,Chrome driver path,
package gmr;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class GMR_AUTOMATION_GMAIL_SENDING {
WebDriver driver;
@BeforeMethod
public void setup(){
System.setProperty("webdriver.chrome.driver", "D:/Selenium/chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
}
@Test
public void gmailMailSednd() throws InterruptedException{
driver.get("http://www.gmail.com/");
/*
* AJax Handling That means Implicitly wait
*/
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
/*
* User Name
*/
driver.findElement(By.xpath(".//*[@id='Email']")).sendKeys("murali.royal123@gmail.com");
/*
* Password
*/
driver.findElement(By.xpath(".//*[@id='Passwd']")).sendKeys("No buddy use your mail and your password");
/*
* Click The Login Button
*/
driver.findElement(By.xpath("//*[@id='signIn']")).click();
/*
* Click The Compose Button
*/
driver.findElement(By.xpath("//div[contains(text(),'COMPOSE')]")).click();
/*
* To Email Address Typing
*/
driver.findElement(By.xpath("//form[1]//textarea[1]")).sendKeys("yoursmail@gmail.com");
/*
* Subject Typing
*/
driver.findElement(By.xpath("//div[@class='aoD az6']//input[@class='aoT']")).sendKeys("Please Find SonarCube IMage attachment");
/*
* Wait For Some Time
*/
Thread.sleep(7000);
/*
* Click The Attachment Icon.
*
*/
/*
* Click The Send Option.
*/
driver.findElement(By.xpath("//div[text()='Send']")).click();
}
@AfterMethod
public void tearDown(){
driver.close();
driver.quit();
}
}
Note Here am not typing any text in the body later i will update for you soon.
package gmr;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class GMR_AUTOMATION_GMAIL_SENDING {
WebDriver driver;
@BeforeMethod
public void setup(){
System.setProperty("webdriver.chrome.driver", "D:/Selenium/chromedriver.exe");
driver = new ChromeDriver();
driver.manage().window().maximize();
}
@Test
public void gmailMailSednd() throws InterruptedException{
driver.get("http://www.gmail.com/");
/*
* AJax Handling That means Implicitly wait
*/
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
/*
* User Name
*/
driver.findElement(By.xpath(".//*[@id='Email']")).sendKeys("murali.royal123@gmail.com");
/*
* Password
*/
driver.findElement(By.xpath(".//*[@id='Passwd']")).sendKeys("No buddy use your mail and your password");
/*
* Click The Login Button
*/
driver.findElement(By.xpath("//*[@id='signIn']")).click();
/*
* Click The Compose Button
*/
driver.findElement(By.xpath("//div[contains(text(),'COMPOSE')]")).click();
/*
* To Email Address Typing
*/
driver.findElement(By.xpath("//form[1]//textarea[1]")).sendKeys("yoursmail@gmail.com");
/*
* Subject Typing
*/
driver.findElement(By.xpath("//div[@class='aoD az6']//input[@class='aoT']")).sendKeys("Please Find SonarCube IMage attachment");
/*
* Wait For Some Time
*/
Thread.sleep(7000);
/*
* Click The Attachment Icon.
*
*/
/*
* Click The Send Option.
*/
driver.findElement(By.xpath("//div[text()='Send']")).click();
}
@AfterMethod
public void tearDown(){
driver.close();
driver.quit();
}
}
Note Here am not typing any text in the body later i will update for you soon.
No comments:
Post a Comment