In my selenium script , I want to get the table data from below table, and compare all values under column 'phone' and check if all the values are only numeric.I tried to use the following code, if is not printing the text of each column, instead it is displaying number of rows.
WebElement table = driver.findElement(By.xpath(“//table[contains(@class, 'table table-style')]”)); List<WebElement> rowsList = table.findElements(By.tagName("tr")); List<WebElement> columnsList = null; for (WebElement row : rowsList) { columnsList = row.findElements(By.tagName("td")); for (WebElement column : columnsList) { System.out.println("column text" + column.getText()+", "); // here is is just printing number of rows, like 1, 2 } }<table class="table table-style" ><thead><tr><th class="text-center"> Id</th><th class="text-center">username</th><th class="text-center">email</th><th class="text-center">phone</th><th class="text-center">address1</th><th class="text-center">address2</th><th class="text-center">City</th></tr></thead><tbody><tr><td class="text-center">Here is user name</td><td class="text-center">email@email.com</td><td class="text-center">123456789</td><td class="text-center">address 1</td><td class="text-center">address 2</td><td class="text-center">city name</td></tr><tr><td class="text-center">Here is user name</td><td class="text-center">email@email.com</td><td class="text-center">99999999</td><td class="text-center">address 1</td><td class="text-center">address 2</td><td class="text-center">city name</td></tr><tr><td class="text-center">Here is user name</td><td class="text-center">email@email.com</td><td class="text-center">abcdef12</td><td class="text-center">address 1</td><td class="text-center">address 2</td><td class="text-center">city name</td></tr></table>