需要依次点击页面的删除按钮,如下图:
@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); }
时间: 2024-10-12 20:24:31