package com.example.test;
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 junit.framework.TestCase;
public class Test163Mail extends TestCase {
private WebDriver driver;
private String baseUrl;
@Override
protected void setUp() throws Exception {
// TODO Auto-generated method stub
driver=new FirefoxDriver();
baseUrl="http://mail.163.com";
driver.manage().timeouts().implicitlyWait(30,TimeUnit.SECONDS);
super.setUp();
}
public void testMail(){
driver.get(baseUrl);
WebElement account=driver.findElement(By.id("idPlaceholder"));
account.sendKeys("*****");
WebElement password=driver.findElement(By.id("pwdInput"));
password.sendKeys("*****");
WebElement submit=driver.findElement(By.id("loginBtn"));
submit.click();
WebElement write=driver.findElement(By.xpath("//span[contains(.,'写 信')]"));
write.click();
WebElement address=driver.findElement(By.className("nui-editableAddr-ipt"));
address.sendKeys("*****@163.com");
WebElement theme=driver.findElement(By.id("objComposeSubject"));
theme.sendKeys("123");
WebElement content = driver.switchTo().frame(driver.findElement(By.className("APP-editor-iframe"))).findElement(By.className("nui-scroll"));
content.sendKeys("123456");
driver.switchTo().defaultContent();
WebElement send=driver.findElement(By.xpath("//span[contains(.,'发送')]"));
send.click();
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
WebElement exit=driver.findElement(By.linkText("退出"));
exit.click();
driver.close();
}
@Override
protected void tearDown() throws Exception {
// TODO Auto-generated method stub
super.tearDown();
}
}