Unable to enter Tolist while sending GMail | Selenium Forum
M
Posted on 21/11/2015
Hi Team,

I am trying to Login into the gmail and send an email to any mail ID.

Attached my script for that.

I am able to click on compose mail and enter the subject successfully .But,I am struck while entering the Tolist.

While trying to enter the To list, it is identifying the xpath I have given , and all the below mentioned steps are getting passed with out throwing any exception. But actual click/sendkeys action is not happening on To list.This is little strange as no exception is thrown but at the same time , no click/sendkeys action is actually performed.I tried using ACTIONS class as I could not achieve it normally.

// entering the tolist
WebElement tolist=driver.findElement(By.xpath("//table//tr//td//div//input[@placeholder='Subject']//../preceding-sibling::div[1]/div"));
act.moveToElement(tolist).clickAndHold(tolist);
Thread.sleep(5000);
act.release(tolist);
tolist.sendKeys("sindhura0101@gmail.com");


Can you pls help me in sorting out this issue.

Thanks,
Sindhu

M
Replied on 22/11/2015

use this





package com.soapuitutorial.propertie;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class AutomateGmail {
public static void main(String[] args) throws InterruptedException {
WebDriver driver=new FirefoxDriver();
try{
driver.get("http://www.gmail.com");
//FirefoxDriverDri=newFirefoxDriver();
//Dri.get("http://gmail.com");
driver.findElement(By.id("Email")).sendKeys("xxxxxxxxxxxxxxx");
driver.findElement(By.id("Passwd")).sendKeys("xxxxxxxxxxxxx");
driver.findElement(By.id("signIn")).click();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.findElement(By.xpath("//div[text()='COMPOSE']")).click();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.xpath("//textarea[@name='to']")).sendKeys("its.thakur@gmail.com");
driver.findElement(By.xpath("//input[@name='subjectbox']")).sendKeys("automated mail by selenium");
driver.findElement(By.xpath("//div[@aria-label='Message Body']")).sendKeys("mail by selenium");
driver.findElement(By.xpath("//div[text()='Send']")).click();


}catch(Exception e){
e.printStackTrace();
e.getMessage();
}
finally{
}
}
}