- syamp
- Posts : 8
Join date : 2012-03-09
How to automated gmail to send email by using Selenium?
Wed Jul 04, 2012 4:05 pm
Hi Friends,
I am trying to automate the gmail to send an email but couldn't able to click on the "Composer" link, for that have tried with Xpaths, Class names,... but not able.
Can anyone please help me out on this. The below code is used for this.
package test;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
public class SendEmail {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "https://accounts.google.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testGmail() throws Exception {
driver.get(baseUrl + "/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2&hl=en");
driver.findElement(By.id("Email")).clear();
driver.findElement(By.id("Email")).sendKeys("abcd");
driver.findElement(By.id("Passwd")).clear();
driver.findElement(By.id("Passwd")).sendKeys("xyz");
driver.findElement(By.id("signIn")).click();
// ERROR: Caught exception [ERROR: Unsupported command [selectFrame]]
driver.findElement(By.xpath("//div[@id=':mq']/div/div")).click();
driver.findElement(By.id(":fz")).clear();
driver.findElement(By.id(":fz")).sendKeys("xyz");
driver.findElement(By.id(":f0")).clear();
driver.findElement(By.id(":f0")).sendKeys("hello");
driver.findElement(By.id("gbg4")).click();
driver.findElement(By.id("gb_71")).click();
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
}
Thanks,
Syam...
I am trying to automate the gmail to send an email but couldn't able to click on the "Composer" link, for that have tried with Xpaths, Class names,... but not able.
Can anyone please help me out on this. The below code is used for this.
package test;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import static org.junit.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
public class SendEmail {
private WebDriver driver;
private String baseUrl;
private StringBuffer verificationErrors = new StringBuffer();
@Before
public void setUp() throws Exception {
driver = new FirefoxDriver();
baseUrl = "https://accounts.google.com/";
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
}
@Test
public void testGmail() throws Exception {
driver.get(baseUrl + "/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1<mpl=default<mplcache=2&hl=en");
driver.findElement(By.id("Email")).clear();
driver.findElement(By.id("Email")).sendKeys("abcd");
driver.findElement(By.id("Passwd")).clear();
driver.findElement(By.id("Passwd")).sendKeys("xyz");
driver.findElement(By.id("signIn")).click();
// ERROR: Caught exception [ERROR: Unsupported command [selectFrame]]
driver.findElement(By.xpath("//div[@id=':mq']/div/div")).click();
driver.findElement(By.id(":fz")).clear();
driver.findElement(By.id(":fz")).sendKeys("xyz");
driver.findElement(By.id(":f0")).clear();
driver.findElement(By.id(":f0")).sendKeys("hello");
driver.findElement(By.id("gbg4")).click();
driver.findElement(By.id("gb_71")).click();
}
@After
public void tearDown() throws Exception {
driver.quit();
String verificationErrorString = verificationErrors.toString();
if (!"".equals(verificationErrorString)) {
fail(verificationErrorString);
}
}
private boolean isElementPresent(By by) {
try {
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
return false;
}
}
}
Thanks,
Syam...
- venugopaldActive particpant
- Posts : 10
Join date : 2012-06-11
Re: How to automated gmail to send email by using Selenium?
Wed Jul 04, 2012 5:59 pm
HI
Place this code above the error comment
driver.switchTo().frame("canvas_frame");
u have to switch to this frame to perform anything in gmail. i tried it & succeded
Place this code above the error comment
driver.switchTo().frame("canvas_frame");
u have to switch to this frame to perform anything in gmail. i tried it & succeded
- syamp
- Posts : 8
Join date : 2012-03-09
Re: How to automated gmail to send email by using Selenium?
Wed Jul 04, 2012 7:45 pm
Thanks venugopal
now i am facing another issue that is unable to write the message in the gamil body. please help me on this.
---------
now i am facing another issue that is unable to write the message in the gamil body. please help me on this.
---------
venugopald wrote:HI
Place this code above the error comment
driver.switchTo().frame("canvas_frame");
u have to switch to this frame to perform anything in gmail. i tried it & succeded
- venugopaldActive particpant
- Posts : 10
Join date : 2012-06-11
Re: How to automated gmail to send email by using Selenium?
Wed Jul 04, 2012 7:55 pm
do one thing take xpath of the body using Firebug and replace the previous body xpath using the latest one. definetely it works...
Re: How to automated gmail to send email by using Selenium?
Wed Jul 04, 2012 8:41 pm
Try out this one
- Code:
driver.findElement(By.xpath("//body")).sendKeys("Test Content");
- Code:
driver.findElement(By.cssSelector("body[class='editable LW-avf']")).sendKeys("body text");
- mckiranlieutenant007@gmai
- Posts : 4
Join date : 2013-04-22
Re: How to automated gmail to send email by using Selenium?
Mon Apr 22, 2013 2:06 am
I have a smart solution for this using Selenium IDE. I could go to composer text area by just using its class (class=editable LW-avf).
I am unable to add any external links here, if anyone need thee code please contact me on my email.
I am unable to add any external links here, if anyone need thee code please contact me on my email.
Permissions in this forum:
You cannot reply to topics in this forum