126邮箱软件测试,selenium测试126邮箱新增联系人

看的书里面有个测试126邮箱新增联系人的功能,用书中的代码已经完全无法定位了,所以就自己去写了代码测试了一下,搞了一下午才搞出来。

登陆的时候他的登陆信息都是放在一个iframe里面的,必须切换到这个frame才能进行操作;

新增联系人页面的定位还是有点困难。

package dhb.appModules;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.ie.InternetExplorerDriver;

import org.openqa.selenium.support.ui.ExpectedConditions;

import org.openqa.selenium.support.ui.WebDriverWait;

import org.testng.Assert;

import org.testng.annotations.Test;

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();

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值