Tuesday, 19 February 2013

Deleting an email and undoing it.

I have tried deleting an email and again undoing it . I was quite successful in it .Check it out..

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;
//import org.openqa.selenium.support.ui.Select;

public class deletingAnEmail {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

    WebDriver d1;
    d1=new FirefoxDriver();
    d1.get("https://mail.google.com/");
    d1.findElement(By.id("Email")).sendKeys("Your Id");
    d1.findElement(By.xpath("//*[@id='Passwd']")).sendKeys("Your password");
    d1.findElement(By.id("signIn")).click();
    d1.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
// This is for deleting.. 
    WebElement checkbox=d1.findElement(By.id(":mf"));
    checkbox.click();
    d1.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    d1.findElement(By.xpath("/html/body/div[5]/div[2]/div/div[2]/div/div[2]/div/div/div/div/div/div/div/div        /div/div[2]/div[3]")).click();
    d1.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
//This is for undoing..  
    d1.findElement(By.xpath("//span[@id='link_undo']")).click();
    d1.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    d1.quit();
    }

}

1 comment:

  1. You can try giving the number of the element like 1 & 2 and try clicking.

    driver.findElements(By.xpath("//*[@role='checkbox']")).get(1).click();

    ReplyDelete