Share
Go down
soumyacr88
Posts : 1
Join date : 2013-06-04

automate gmail to sent email using webdriver

on Wed Jun 05, 2013 12:03 pm
Hi,

Can someone please help me to automate sending email in Gmail.

I am not able to add "to Address" .

Please find my code below
WebElement name=driver.findElement(By.name("Email"));
name.click();
name.sendKeys("email");
WebElement password=driver.findElement(By.id("Passwd"));
password.click();
password.sendKeys("Password");
WebElement Signin=driver.findElement(By.id("signIn"));
Signin.click();

driver.switchTo().frame("canvas_frame");
WebDriverWait mywait=new WebDriverWait(driver, 30);
mywait.until(ExpectedConditions.elementToBeClickable(By.cssSelector(".aic .z0")));

WebElement compose=driver.findElement(By.cssSelector("div[class='T-I J-J5-Ji T-I-KE L3']"));
compose.click();
System.out.println("compose Clicked");
WebElement ToAdd=driver.findElement(By.className(".vO"));
ToAdd.clear();
ToAdd.click();
ToAdd.sendKeys("Toaddress");
tarun3kumar
Master
Master
Posts : 186
Join date : 2012-02-14
http://seleniumtests.com

Re: automate gmail to sent email using webdriver

on Wed Jun 05, 2013 1:11 pm
asked and answered many times. Don't try to automate Gmail using Selenium.
Rather user mail API available in programming language of your choice to carry out mail activity.

_________________
Thanks
Tarun K
Free Selenium Training
sree.cs10@gmail.com
Posts : 3
Join date : 2013-06-10
Age : 29
Location : Hyderabad

Sending Email from Gmail..

on Tue Jun 18, 2013 12:16 am
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import java.util.concurrent.TimeUnit;

public class SendEmailFromGmail {
public static void main(String[] args) throws Exception {
WebDriver fd=new FirefoxDriver();
fd.get("http://www.gmail.com");
fd.findElement(By.id("Email")).click();
fd.findElement(By.id("Email")).sendKeys("username@gmail.com");
fd.findElement(By.id("Passwd")).click();
fd.findElement(By.id("Passwd")).sendKeys("password");
fd.findElement(By.id("signIn")).click();
fd.manage().timeouts().implicitlyWait(100,TimeUnit.SECONDS);
fd.findElement(By.xpath("/html/body/div[5]/div[2]/div/div[2]/div/div/div/div[2]/div/div/div/div/div")).click();
fd.findElement(By.className("vO")).click();
fd.findElement(By.className("vO")).sendKeys("ToUserID@gmail.com");
fd.findElement(By.className("aoT")).click();
fd.findElement(By.className("aoT")).sendKeys("Email Subject: Hiiiii");
fd.findElement(By.xpath("/html/body/div[9]/div/div/div/div/div[2]/div/div/div/div/div/div[3]/div/div/div[4]/table/
tbody/tr/td[2]/table/tbody")).click();
fd.findElement(By.xpath("/html/body/div[9]/div/div/div/div/div[2]/div/div/div/div/div/div[3]/div/div/div[4]/table/
tbody/tr/td[2]/table/tbody")).sendKeys("Writing email body");
fd.findElement(By.cssSelector("div[class='T-I J-J5-Ji aoO T-I-atl L3']")).click();
}
}
sree.cs10@gmail.com
Posts : 3
Join date : 2013-06-10
Age : 29
Location : Hyderabad

Re: automate gmail to sent email using webdriver

on Tue Jun 18, 2013 12:17 am
Hi soumyacr88,

Above code is worked on my machine. Pls try and let me know if you are facing any problems.

Thanks,
Srikanth


Last edited by sree.cs10@gmail.com on Tue Jun 18, 2013 12:18 am; edited 1 time in total (Reason for editing : Few corrections)
Sponsored content

Re: automate gmail to sent email using webdriver

Back to top
Permissions in this forum:
You cannot reply to topics in this forum