Tuesday, 19 February 2013

Deleting multiple emails and undoing it.

Once you got to know how to check a box, ,It is easy to click on one or multiple checkboxes.Which enables us to automate options like deleting multiple emails.

Here is the code below:

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 deletingMultiplemails {

    /**
     * @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);
    WebElement checkbox1=d1.findElement(By.id(":mf"));
    checkbox1.click();
    WebElement checkbox2=d1.findElement(By.id(":m5"));
    checkbox2.click();
    WebElement checkbox3=d1.findElement(By.id(":lv"));
    checkbox3.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.findElement(By.xpath("//div[@class='oZ-jc T-Jo J-J5-Ji T-Jo-Jp']")).click()
    d1.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    d1.findElement(By.xpath("//span[@id='link_undo']")).click();
    d1.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
    d1.quit();
    }

}

No comments:

Post a Comment