Package org.openqa.selenium.chrome

Examples of org.openqa.selenium.chrome.ChromeDriver.findElements()


   
    dr.get(filePath);
    Thread.sleep(1000);
   
//    选择所有的checkbox并全部勾上
    List<WebElement> checkboxes = dr.findElements(By.cssSelector("input[type=checkbox]"));
    for(WebElement checkbox : checkboxes) {
      checkbox.click();
    }
    dr.navigate().refresh();
   
View Full Code Here


   
//    打印当前页面上有多少个checkbox
    System.out.printf("%d\n", checkboxes.size());
   
//    选择页面上所有的input,然后从中过滤出所有的checkbox并勾选之
    List<WebElement> inputs = dr.findElements(By.tagName("input"));
    for(WebElement input : inputs){
      if(input.getAttribute("type").equals("checkbox")){
        input.click();
      }
    }
View Full Code Here

        input.click();
      }
    }
   
//    把页面上最后1个checkbox的勾给去掉
    List<WebElement> allCheckboxes = dr.findElements(By.cssSelector("input[type=checkbox]"));
    allCheckboxes.get(allCheckboxes.size() - 1).click();
   
    Thread.sleep(1000);
    System.out.println("browser will be close");
    dr.quit()
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.