selenium依次点击页面的删除按钮

需要依次点击页面的删除按钮,如下图:

selenium依次点击页面的删除按钮

	@Test
public static void FaBu() { TestMenuJump.jumpExam(driver); TestMenuJump.jumpExamPa(driver); WebElement wes = driver.findElement(By.id("Category"));
Select sc = new Select(wes);
sc.selectByIndex(3);
wes.submit(); //driver.findElement(By.id("Content")).sendKeys(""+i);
//driver.findElement(By.className("btn btn-info btn-sm"));
WebElement we = driver.findElement(By.linkText("下一页"));
do{
List<WebElement> list = driver.findElements(By.linkText("删除"));
if(list.size()>0) {
for(int i=0;i<list.size();i++) {
driver.findElement(By.linkText("删除")).click();
Alert alert = driver.switchTo().alert();
alert.dismiss(); }
}
System.out.println(list.size());
/*for(WebElement we1:list) {
we1.click();
Alert alert = driver.switchTo().alert();
alert.dismiss();
}*/
try{
WebElement wel = driver.findElement(By.linkText("下一页"));
wel.click();
}catch(NoSuchElementException e){
System.out.println("结束");
we = null;
}
}while(we != null); }

  

上一篇:使用Oracle安装账户登录数据库


下一篇:javascript优化--07模式(对象)02