TA的每日心情 | 奋斗 2016-9-10 11:32 |
---|
签到天数: 1 天 连续签到: 1 天 [LV.1]测试小兵
|
package com.brooke.test;
import static org.junit.Assert.*;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class sss {
private static WebDriver driver=null;
@BeforeClass
public static void setUpBeforeClass() throws Exception {
System.setProperty("webdriver.chrome.driver", "Files\\chromedriver.exe");
driver=new ChromeDriver();
}
@AfterClass
public static void tearDownAfterClass() throws Exception {
}
@Test
public void test() {
driver.get("http://192.168.5.14:8086/login");
WebElement username=driver.findElement(By.name("username"));//识别用户名文本框元素
WebElement password=driver.findElement(By.name("password"));//识别密码文本框元素
WebElement captcha=driver.findElement(By.name("captcha"));//识别验证码输入框
WebElement login=driver.findElement(By.className("clearfix"));//识别登录按钮
char[] cha={'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
String s=null;
for(int i=0;i<cha.length;i++){
username.sendKeys("haolei");
password.sendKeys("Htche123465");
s=String.valueOf(cha[i]);
System.out.println("验证码是"+s);
captcha.sendKeys(s);
login.submit();
System.out.println("第"+i+"次尝试");
System.out.println(cha.length);
}
}
}
|
|