samedi 4 juillet 2015

Div tag acting as buttons, and also Dynamic buttons like delete, report spam, etc

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); }

Aucun commentaire:

Enregistrer un commentaire