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:

 

评分:0

我来说两句

我的栏目

日历

« 2024-03-28  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

我的存档

数据统计

  • 访问量: 1545
  • 日志数: 1
  • 建立时间: 2017-12-07
  • 更新时间: 2017-12-07

RSS订阅

Open Toolbar