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
syamp
Posts : 8
Join date : 2012-03-09

How to automated gmail to send email by using Selenium? Empty 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...
avatar
venugopald
Active particpant
Active particpant
Posts : 10
Join date : 2012-06-11

How to automated gmail to send email by using Selenium? Empty 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
avatar
syamp
Posts : 8
Join date : 2012-03-09

How to automated gmail to send email by using Selenium? Empty 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.
---------


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
avatar
venugopald
Active particpant
Active particpant
Posts : 10
Join date : 2012-06-11

How to automated gmail to send email by using Selenium? Empty 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...
rohit13
rohit13
Master
Master
Posts : 180
Join date : 2012-03-29
Age : 37
Location : INDIA
http://radical-qa.blogspot.in/

How to automated gmail to send email by using Selenium? Empty 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");
OR
Code:
driver.findElement(By.cssSelector("body[class='editable  LW-avf']")).sendKeys("body text");
avatar
mckiranlieutenant007@gmai
Posts : 4
Join date : 2013-04-22

How to automated gmail to send email by using Selenium? Empty 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.
Sponsored content

How to automated gmail to send email by using Selenium? Empty Re: How to automated gmail to send email by using Selenium?

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