Please explain the logic | Selenium Forum
M
Posted on 13/01/2016
Send email query:

after opening gmail , clicked in compose:
after that belwo is code

driver.findElement(By.xpath("//div[@class='aoI']/table/tbody/tr/td[2]/form/div/table/tbody/tr/td[2]/div/div/textarea")).sendKeys("xxx.919@gmail.com");
driver.findElement(By.xpath("//div[@class='aoX']/div/table/tbody/tr/td[2]/div[2]/div")).sendKeys("This is a test mail");
driver.findElement(By.xpath("//div[@class='aoI']/table/tbody/tr/td[2]/form/div[3]/input")).sendKeys("Time Pass");


Working fine but if i write:

Ist line after other two line , getting element not visible error:
Tried many times. Please explain why

I mean like this:
driver.findElement(By.xpath("//div[@class='aoX']/div/table/tbody/tr/td[2]/div[2]/div")).sendKeys("This is a test mail");
driver.findElement(By.xpath("//div[@class='aoI']/table/tbody/tr/td[2]/form/div[3]/input")).sendKeys("Time Pass");
driver.findElement(By.xpath("//div[@class='aoI']/table/tbody/tr/td[2]/form/div/table/tbody/tr/td[2]/div/div/textarea")).sendKeys("xxx.919@gmail.com");

M
Replied on 13/01/2016

attaching screenshot.

Responsive image

M
Replied on 13/01/2016

use this code to send emails

[code:3s6y4idg]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{
}
}
}[/code:3s6y4idg]