selenium java 书_eclipse+java+selenium+testNG搭建自动化测试框架

登录页面相关测试用例

package com.zzx.test;

import static org.testng.Assert.assertEquals;

import org.testng.annotations.Test;

import com.zzx.pageObject.LoginPage;

import com.zzx.util.BaseTest;

public class LoginTest extends BaseTest{

LoginPage loginPage = new LoginPage();

String LoginURL = "http://oneadmin.peersafe.cn/logout";

/**

* 方法名称:loginTest1

* 方法描述: This method is testing the empty username and the right password

*         The end is Loginfailed ,I will print some error information  on the console and

*         the page still stay on the login page

* 创建人:zzx

* 创建时间:2017年9月12日 下午5:33:27

* 修改人:zzx

* 修改时间:2017年9月12日 下午5:33:27

* 修改备注:

* @version  1.0

* @throws Exception maybe some exception will happen

*/

//空的用户名和正确的密码,登录失败,控制台输出“用户名错误!”

@Test(priority=1)

public void loginTest1() throws Exception{

if(!loginPage.isLoginPage(driver)){

driver.get(LoginURL);

}

try {

loginPage.login(driver, "","$z58dSHE");

} catch (Exception e) {

System.out.println(e);

}

finally {

assertEquals(false, loginPage.loginStatus(driver));

}

}

/**

* 方法名称:loginTest2

* 方法描述: This method is testing the empty username and the error password

*         The end is Loginfailed ,I will print some error information  on the console and

*         the page still stay on the login page

* 创建人:zzx

* 创建时间:2017年9月12日 下午5:33:27

* 修改人:zzx

* 修改时间:2017年9月12日 下午5:33:27

* 修改备注:

* @version  1.0

* @throws Exception maybe some exception will happen

*/

//空的用户名和错误的密码,登录失败,控制台输出“用户名错误!”

@Test(priority=2)

public void loginTest2() throws Exception{

if(!loginPage.isLoginPage(driver)){

driver.get(LoginURL);

}

try {

loginPage.login(driver, "","$z58dSH");

} catch (Exception e) {

System.out.println(e);

}

finally {

assertEquals(false, loginPage.loginStatus(driver));

}

}

/**

* 方法名称:loginTest3

* 方法描述: This method is testing the right username and the empty password

*         The end is Loginfailed ,I will print some error information  on the console and

*         the page still stay on the login page

* 创建人:zzx

* 创建时间:2017年9月12日 下午5:33:27

* 修改人:zzx

* 修改时间:2017年9月12日 下午5:33:27

* 修改备注:

* @version  1.0

* @throws Exception maybe some exception will happen

*/

//正确用户名和空的密码,登录失败,控制台输出“密码不正确”

@Test(priority=3)

public void loginTest3() throws Exception{

if(!loginPage.isLoginPage(driver)){

driver.get(LoginURL);

}

try {

loginPage.login(driver, "admin","");

} catch (Exception e) {

System.out.println(e);

}

finally {

assertEquals(false, loginPage.loginStatus(driver));

}

}

/**

* 方法名称:loginTest4

* 方法描述: This method is testing the error username and the empty password

*         The end is Loginfailed ,I will print some error information  on the console and

*         the page still stay on the login page

* 创建人:zzx

* 创建时间:2017年9月12日 下午5:33:27

* 修改人:zzx

* 修改时间:2017年9月12日 下午5:33:27

* 修改备注:

* @version  1.0

* @throws Exception maybe some exception will happen

*/

//错误用户名和空的密码,登录失败,控制台输出“用户名错误!”

@Test(priority=4)

public void loginTest4() throws Exception{

if(!loginPage.isLoginPage(driver)){

driver.get(LoginURL);

}

try {

loginPage.login(driver, "admim","");

} catch (Exception e) {

System.out.println(e);

}

finally {

assertEquals(false, loginPage.loginStatus(driver));

}

}

/**

* 方法名称:loginTest5

* 方法描述: This method is testing the empty username and the empty password

*         The end is Loginfailed ,I will print some error information  on the console and

*         the page still stay on the login page

* 创建人:zzx

* 创建时间:2017年9月12日 下午5:33:27

* 修改人:zzx

* 修改时间:2017年9月12日 下午5:33:27

* 修改备注:

* @version  1.0

* @throws Exception maybe some exception will happen

*/

//空的用户名和空的密码,登录失败,控制台输出“用户名错误!”

@Test(priority=5)

public void loginTest5() throws Exception{

if(!loginPage.isLoginPage(driver)){

driver.get(LoginURL);

}

try {

loginPage.login(driver, "","");

} catch (Exception e) {

System.out.println(e);

}

finally {

assertEquals(false, loginPage.loginStatus(driver));

}

}

/**

* 方法名称:loginTest6

* 方法描述: This method is testing the error username and the error password

*         The end is Loginfailed ,I will print some error information  on the console and

*         the page still stay on the login page

* 创建人:zzx

* 创建时间:2017年9月12日 下午5:33:27

* 修改人:zzx

* 修改时间:2017年9月12日 下午5:33:27

* 修改备注:

* @version  1.0

* @throws Exception maybe some exception will happen

*/

//错误用户名和错误的密码,登录失败,控制台输出“用户名错误!”

@Test(priority=6)

public void loginTest6() throws Exception{

if(!loginPage.isLoginPage(driver)){

driver.get(LoginURL);

}

try {

loginPage.login(driver, "admim","$z58dSH");

} catch (Exception e) {

System.out.println(e);

}

finally {

assertEquals(false, loginPage.loginStatus(driver));

}

}

/**

* 方法名称:loginTest7

* 方法描述: This method is testing the right username and the error password

*         The end is Loginfailed ,I will print some error information  on the console and

*         the page still stay on the login page

* 创建人:zzx

* 创建时间:2017年9月12日 下午5:33:27

* 修改人:zzx

* 修改时间:2017年9月12日 下午5:33:27

* 修改备注:

* @version  1.0

* @throws Exception maybe some exception will happen

*/

//正确用户名和错误的密码,登录失败,控制台输出“密码不正确”

@Test(priority=7)

public void loginTest7() throws Exception{

if(!loginPage.isLoginPage(driver)){

driver.get(LoginURL);

}

try {

loginPage.login(driver, "admin","$z58dSH");

} catch (Exception e) {

System.out.println(e);

}

finally {

assertEquals(false, loginPage.loginStatus(driver));

}

}

/**

* 方法名称:loginTest8

* 方法描述: This method is testing the error username and the right password

*         The end is Loginfailed ,I will print some error information  on the console and

*         the page still stay on the login page

* 创建人:zzx

* 创建时间:2017年9月12日 下午5:33:27

* 修改人:zzx

* 修改时间:2017年9月12日 下午5:33:27

* 修改备注:

* @version  1.0

* @throws Exception maybe some exception will happen

*/

//错误用户名和正确密码,登录失败,控制台输出“用户名错误!”

@Test(priority=8)

public void loginTest8() throws Exception{

if(!loginPage.isLoginPage(driver)){

driver.get(LoginURL);

}

try {

loginPage.login(driver, "admim","$z58dSHE");

} catch (Exception e) {

System.out.println(e);

}

finally {

assertEquals(false, loginPage.loginStatus(driver));

}

}

/**

* 方法名称:loginTest9

* 方法描述: This method is testing the right username and the right password

*         The end is successed ,I will print some successed information  on the console and

*         the page will into the home page

* 创建人:zzx

* 创建时间:2017年9月12日 下午5:33:27

* 修改人:zzx

* 修改时间:2017年9月12日 下午5:33:27

* 修改备注:

* @version  1.0

* @throws Exception maybe some exception will happen

*/

//正确用户名和正确密码,登录成功,控制台输出“登录成功!”

@Test(priority=9)

public void loginTest9() throws Exception{

if(!loginPage.isLoginPage(driver)){

driver.get(LoginURL);

}

try {

loginPage.login(driver, "admin","$z58dSHE");

} catch (Exception e) {

System.out.println(e);

}

finally {

assertEquals(true, loginPage.loginStatus(driver));

}

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值