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