zoukankan      html  css  js  c++  java
  • 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);
    		
    	}
    

      

  • 相关阅读:
    C++ *和&
    leetcode 338. Bit位计数
    leetcode 216. 组合总和 III
    leetcode 40. 组合总和 II
    c++ vector 常用函数
    leetcode 491. 递增子序列
    leetcode 441. 排列硬币
    leetcode 258. 各位相加
    leetcode 415. 字符串相加
    leetcode 67. 二进制求和
  • 原文地址:https://www.cnblogs.com/qiaoyeye/p/4608310.html
Copyright © 2011-2022 走看看