Selenium Forum: Functional And Regression Testing Tool.
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
AEM Training | Free Online DemoWed Apr 21, 2021 5:45 pmazharuddin
c# PageFactory - issue initializing elementsFri Nov 01, 2019 8:40 pmthegoatboy
Selenium making automatic connection to random urlsMon Jul 08, 2019 12:58 pmrepairtechsolutions1
How can we design the custom framework in Selenium RCMon Jun 24, 2019 2:26 pmrandybonnettes
What are the new features in Selenium 3.0Tue Jun 18, 2019 5:37 pmpappyvicky
What are you using Selenium for? Fri Apr 12, 2019 3:52 amzhl
LIMITATIONS OF SELENIUMWed Apr 10, 2019 11:23 amswara
Navigation
 Portal
 Index
 Memberlist
 Profile
 FAQ
 Search

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

automate gmail to sent email using webdriver Empty automate gmail to sent email using webdriver

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");
avatar
tarun3kumar
Master
Master
Posts : 186
Join date : 2012-02-14
http://seleniumtests.com

automate gmail to sent email using webdriver Empty Re: automate gmail to sent email using webdriver

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.
avatar
sree.cs10@gmail.com
Posts : 3
Join date : 2013-06-10
Age : 35
Location : Hyderabad

automate gmail to sent email using webdriver Empty Sending Email from Gmail..

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();
}
}
avatar
sree.cs10@gmail.com
Posts : 3
Join date : 2013-06-10
Age : 35
Location : Hyderabad

automate gmail to sent email using webdriver Empty Re: automate gmail to sent email using webdriver

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

automate gmail to sent email using webdriver Empty Re: automate gmail to sent email using webdriver

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