mercredi 16 août 2017

Selenium Java : Handling check boxes

I have to test a question-answer module where user will enter answers through check box. There are total 5 j-query tabs with some questions. and it will move to other tab if answers are given and clicked "Save and next" button. I am going following way but it is not selecting every check box. because some check boxes are not displayed. Can someone suggest better way to select each and every checkbox?

List<WebElement> chkbx = driver.findElements(By.xpath("//input[@type='checkbox']"));
int j=1;
while(j<5){
for(int i = 0;i<chkbx.size();i++){
    if(chkbx.get(i).isDisplayed()){
        chkbx.get(i).click();
    }
}
driver.findElement(By.xpath("x-path of save button")).click();
j++;
}

Aucun commentaire:

Enregistrer un commentaire