0

Trying to delete remove button after adding the products used for loop to delete the records one by one before signout the testcase

But its deleting only one record ,i would like to delete the records until its reach to table count zero

   ` List<WebElement> rows = driver.findElements(xpath);
        // For loop follows
        for (int i = 0; i < rows.size(); i++) {
            // Access individual elements this way:
            WebElement deleteButton = driver.findElement(xpath);
            deleteButton.click();
        }`
sarath k
  • 3
  • 2
  • So you have one remove button that delete the rows? Or does each row have the remove button? – Success Shrestha Jul 13 '23 at 09:15
  • yes i have multiple rows with remove btn and current code is working with delete the only one remove button .my question is to delete the all the rows remote button until the table size equal to zero – sarath k Jul 13 '23 at 12:23
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Jul 13 '23 at 15:53

1 Answers1

0

Probably you should search from root element from each row. It looks like you are trying to click on the same element in your loop each time.

Try this

 List<WebElement> rows = driver.findElements(rowsXpath);
        // For loop follows
 for (WebElement element: rows) {
            // Access individual elements this way:
            WebElement deleteButton = element.findElement(deleteButtonXpath);
            deleteButton.click();
            // there I suggest to add some wait for rows amount to be decreased
}`
Yaroslavm
  • 1,762
  • 2
  • 7
  • 15