2.编码,贴下通行证登录模块的代码,供参考
  测试类:PassportLogin

 

public class PassportLogin extends BaseTest {
private static Logger log = Logger.getLogger(PassportLogin.class);
@DataProvider(name = "passportLoginData")
public static Object[][] passportLoginData() {
return new Object[][] {
{ "正确的网易通行证登录", "xxxxx@163.com", "xxxxx", "" },
{ "非网易账号的网易通行证登录", "xxx@qq.com", "xxxx", "" },
{ "网易通行证登录,密码错误", "xxxx@163.com", "xxx",
"用户名或密码错误" },
{ "不输入账号和密码", "", "", "用户名不能为空" },
{ "不输入密码", "xxx@163.com", "", "密码不能为空" },
{ "不输入账号", "", "xxxx", "用户名不能为空" },
{ "错误的网易通行证登录", MyRandom.getRandomString(10) + "@163.com",
MyRandom.getRandomString(6), "用户名或密码错误" } };
}
@BeforeClass
public void setUp() {
driver = new Orange();
mainPage = new MainPage(driver);
account = new Account(driver);
as = new AssertSettings(driver);
usPage = new UserSettingsPage(driver);
homePage = new HomePage(driver);
mainPage.enterMainPage();
mainPage.enterLogin();
account.logoutTrue();
}
@AfterClass
public void tearDown() {
driver.quit();
}
@AfterMethod
public void end() throws InterruptedException {
log.info("-------------------------------------------------------------------");
}
@Test(dataProvider = "passportLoginData")
public void passportLoginTest(String testName, String passport,
String password, String errorCode) throws InterruptedException {
log.info("测试内容:" + testName);
mainPage.enterLogin();
account.login(passport, password);
if (errorCode != "") {
boolean b = as.assertLogin(errorCode);
driver.sleep(3000);
mainPage.flickToRight();
mainPage.closePage();
Assert.assertTrue(b);
} else {
mainPage.enterLogin();
homePage.settingsClick();
usPage.passportClick();
account.logout();
}
}
}