一个简单的登录用例

package info.itest.www;
import static org.junit.Assert.*;
import org.openqa.selenium.*;
import org.openqa.selenium.firefox.FirefoxDriver;
import bsh.commands.dir;
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 = "a00";
        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();
    }

}

posted @ 2017-12-07 10:49  刘巨宝  阅读(159)  评论(0编辑  收藏  举报