selenuim+junit 创建登录测试用例
上一篇 /
下一篇 2017-12-07 15:11:24 / 天气: 晴朗
/ 心情: 高兴
/ 精华(3)
/ 置顶(3)
/ 个人分类:selenium
package info.itest.www;
import static org.junit.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class CreatePost {
WebDriver dr;
@Before
public void setUp() throws Exception {
this.dr = new FirefoxDriver();
}
@After
public void tearDown() throws Exception {
this.dr.quit();
}
@Test
public void testLogin() {
String userName = "a0";
String password = "123<>?qweQWE";
this.login(userName, password);
/*登录成功的url 设置断言*/
assertTrue(dr.getCurrentUrl().contains("indexnew.show"));
}
public void login(String userName,String password ) {
dr.get("http://login.eufei360.com/login?service=http%3A%2F% 2Fwww.eufei360.com%2Fj_spring_cas_security_check");
dr.findElement(By.id("loginname")).sendKeys(userName);
dr.findElement(By.id("nloginpwd")).sendKeys(password);
dr.findElement(By.id("loginButton")).click();
}
}
收藏
举报
TAG: