public class loginTest {
WebDriver driver;br/>@Test(dataProvider="testData")
public void openWeb(String webUrl,String cname,String btn,String rgt) {
driver.navigate().to(webUrl);
driver.findElement(By.className(cname)).click();
if(webUrl!="xxxxx") {
WebElement email=driver.findElement(By.xpath("//div[@class='userLogin']/div[1]/input[@id='email']"));br/>email.sendKeys("[email protected]");
driver.findElement(By.xpath("//div[@class='userLogin']/div[2]/input[@id='password']")).sendKeys("xxxx");
WebElement button=driver.findElement(By.id("loginButton"));
button.click();
Assert.assertEquals(btn, button.getText());br/>}else
{
driver.findElement(By.name("login_email")).sendKeys("[email protected]");
driver.findElement(By.name("login_password")).sendKeys("[email protected]");}
}
@DataProvider(name="testData")
br/>driver.findElement(By.id("login_submit")).click();
}
}
@DataProvider(name="testData")
public static Object[][] dataBase(){
return new Object[][] {
{"xxx","touXiang","Login","Register Now"},{"xxx","touXiang","Login","Register Now"},{"xxx","touXiang","Login","Register Now"},{"xxx","touXiang","Login","Register Now"},{"xxxr","touXiang","Login","Register Now"},{"xxx","touXiang","Login","Register Now"},{"xxx","touXiang","Login","Register Now"},
{"xxx","touXiang","Login","Register Now"},{"xxx","touXiang","Login","Register Now"},{"xxx","touXiang","Login","Register Now"},{"xxx","touXiang","Login","Register Now"},{"xxx","customer poRe","Login","Register Now"}
};
}

@BeforeClass
public void beforeClass() {
//修改浏览器语言
ChromeOptions op=new ChromeOptions();
op.addArguments("--lang=en-US");
//初始化一个chrome浏览器实例,实例名称叫driver
driver = new ChromeDriver(op);
//浏览器窗口最大化
driver.manage().window().maximize();
//设置页面资源加载时间
//driver.manage().timeouts().pageLoadTimeout(5, TimeUnit.SECONDS);
//设置页面元素查找时间
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
}

@AfterClass
public void afterClass() {
driver.close();//关闭浏览器
}

}