Inbox | Selenium Forum
M
Posted on 08/08/2016
Hi Ashish,
How to send a mail. Up to clicking on compose it is working fine.Message box in webtable form.
//not working--tried to do using table.td.tr concept but unable to loacte the exact div.




package interview;

import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;

public class gmail {
public static void main(String[] args) throws InterruptedException {
WebDriver driver=new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.get("https://accounts.gmail.com");
driver.findElement(By.xpath("//*[@id='Email']")).sendKeys("'jyosh.maddy@gmail.com");
driver.findElement(By.xpath("//*[@id='next']")).click();
driver.findElement(By.xpath("//*[@id='Passwd']")).sendKeys("Not specifying password");
driver.findElement(By.xpath("//*[@id='signIn']")).click();


//compose
driver.findElement(By.xpath("//*[@id=':it']/div/div")).click();

//not working

driver.findElement(By.xpath("//*[@id=':it']/div/div")).click();


driver.findElement(By.xpath("//*[@id=':pr']")).sendKeys("jyosh.maddy@gmail.com");
driver.findElement(By.xpath("//*[@id=':q1']")).sendKeys("Hi");
driver.findElement(By.xpath("//*[@id=':ow']")).sendKeys("jyosh");

driver.findElement(By.xpath("//*[@id=':m5']")).click();





}


}

M
Replied on 08/08/2016

[code:2cx4c2b8]package com.soapuitutorial.propertie;

import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;

public class SendGMail {
public static WebDriver driver;

public static void main(String[] args) throws InterruptedException
{
driver= new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("https://gmail.com/");
driver.manage().window().maximize();
Actions act= new Actions(driver);

//logging into gmail and opening the inbox
driver.findElement(By.xpath("//*[@id='Email']")).sendKeys("qtpselenium.supp0rt@gmail.com");
driver.findElement(By.xpath("//*[@id='next']")).click();
driver.findElement(By.xpath("//*[@id='Passwd']")).sendKeys("m0b1l390n3"); //password hided intensionally
driver.findElement(By.xpath("//*[@id='signIn']")).click();

//click on compose button
driver.findElement(By.xpath("//div[text()='COMPOSE']")).click();

//entering the subject
WebElement subject=driver.findElement(By.xpath("//table//tr//td//div//input[@placeholder='Subject']"));
subject.sendKeys("testmail");

// 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");


driver.close();





}
}
[/code:2cx4c2b8]


M
Replied on 09/08/2016

Hi Ashish
Inbox --unable to print in toloist box
Thank you for all of your responses for my questions.
The xpath you used here are so weird.How can I identify and learn more about this xpath and xpath Axes.
Do you have any documentation or any suggested tutorials on Xpath Axes.
I have seen Xpath Axes but bit confusing to move back and forth using following-sibling,preceding-sibiling to descendant to childs.
why are you using // overall here
what is the meaning of 0L when initializing to long.eg int height=0L;

Thank you.

Responsive image

M
Replied on 10/08/2016

why do you want to automate gmail?

Google products are one of the most difficult websites to automate.