This is a practice test case where i have to login to gmail and click on all the checkbox in the dynamic web table and delete the mails. So i made the following code.
The problem is when i am checking the delete button is available or not. It is returning true but when i am trying to perform the delete operation it is displaying ElementNotVisibleException
. FYI i am able to select all the checkboxes. Only issue is clicking on the buttons made from tag.
//deleting mail by clicking on all checkbox
int count = 1;
List<WebElement> lst = driver.findElements(By.xpath(cbox));
System.out.println("Total number of checkboxes are \t: " + lst.size());
for(int i=0;i<lst.size();i++){
WebElement wwe = lst.get(i);
wwe.click();
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
System.out.println("Checked on checkbox number \t: " + count);
count++;
}
driver.manage().timeouts().implicitlyWait(3, TimeUnit.SECONDS);
try{
boolean flag = driver.findElement(By.xpath(delete)).isEnabled();
if(flag){
System.out.println("\nDelete button is enabled");
}else{
System.out.println("\nDelete button is not enabled");
}
driver.findElement(By.xpath(delete)).click();
}catch(Throwable t){
System.out.println("\nUnable to locate delete button");
System.out.println("The exception occuring is \t: " + t);
}
I've tried the following and it worked fine.You just have to add enough wait
You probably chose not so automation friendly web app like Gmail to start with. I believe they have deliberately developed Gmail client side in such a way that its harder for a Robot to perform actions.
As for your question, I think the delete button appears a little after check boxes are clicked. So I believe you will have to explicitly wait for the button to appear. It's also possible that your xpath is not correct.
You could try this,