public class NewTest {
@Test
public void f() {
WebDriver driver=new InternetExplorerDriver();
driver.get("
http://mail.126.com/");
WebElement ifr=driver.findElement(By.tagName("iframe"));
driver.switchTo().frame(ifr);
WebElement name=driver.findElement(By.xpath("//input[@name='email']"));
name.clear();
name.sendKeys("**********你的账号名称*********");
WebElement pswd=driver.findElement(By.name("password"));
pswd.clear();
pswd.sendKeys("*****你申请账号的密码*********");
System.out.println(driver.getWindowHandle().toString());
WebElement button=driver.findElement(By.id("dologin"));
button.click();
driver.switchTo().defaultContent();
System.out.println(driver.getTitle());
WebDriverWait wait=new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.textToBePresentInElement(By.id("spnUid"), "*****你申请的账号
+@126.com*****"));
System.out.println(driver.getTitle());
Assert.assertTrue(driver.getPageSource().contains("未读邮件"));
driver.findElement(By.xpath("//div[@id='dvMultiTab']/ul/li[2]/div[3]")).click();
WebElement pp=driver.findElement(By.xpath("//div[@id='dvContainer']/div/header/div/div[1]/div/span[2]"));
System.out.println(pp.getAttribute("class"));
pp.click();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
WebElement username=driver.findElement(By.xpath("//div[@id='contact_edit_main_normal']/dl[1]/dd/div/input"));
WebElement email=driver.findElement(By.xpath("//div[@id='iaddress_MAIL_wrap']/dl/dd/div/input"));
WebElement telno=driver.findElement(By.xpath("//div[@id='iaddress_TEL_wrap']/dl/dd/div/input"));
WebElement beizhu=driver.findElement(By.xpath("//div[@id='contact_edit_main_normal']/dl[3]/dd/div/textarea"));
WebElement submit=driver.findElement(By.xpath("//div[starts-with(@id,'_mail_msgbox_')]/div[3]/div[2]/div[1]/span"));
username.sendKeys("棉花糖");
email.sendKeys("棉花糖@qq.com");
telno.sendKeys("13555555555");
beizhu.sendKeys("这是牛逼人物");
submit.click();
}
}