Here i'm getting all checkboxes of a page but unable to select all check boxes when i tried below code its giving error.Here is my code `public class AllCheckBoxes {
public static void main(String[] args) throws InterruptedException {
WebDriver driver = new FirefoxDriver();
driver.get("http://ift.tt/1QSYmgU");
Thread.sleep(1000);
try {
// Option 1
List<WebElement> CHECKBOXlist = driver.findElements(By.xpath("//input[@type='checkbox']"));
// Option 2
//List<WebElement> CHECKBOXlist = driver.findElements(By.cssSelector("[type='checkbox']"));
System.out.println("Total Check Boxes are avaliable here are: "+CHECKBOXlist.size());
for (WebElement checkbox : CHECKBOXlist) {
checkbox.click();
}
} catch (Exception e) {
System.out.println(e.getMessage());
// Error as: Element is no longer attached to the DOM
// For documentation on this error, please visit: http://ift.tt/1h3Z8lU
}
driver.quit();
}
}` Can anybody guide me how to do this?
Aucun commentaire:
Enregistrer un commentaire