I am trying to count the total number of rows (excluding header) in my HTML table using Selenium Webdriver-Java.
Can someone please guide me in correct direction regarding the steps for the same?
Thanks in advance!
I am trying to count the total number of rows (excluding header) in my HTML table using Selenium Webdriver-Java.
Can someone please guide me in correct direction regarding the steps for the same?
Thanks in advance!
If you could provide HTML around your table, we could provide more accurate selector in your case. Something like this should work. Hope you get the idea!
List<WebElement> rows = driver.findElements(By.cssSelector("table#dummyTable>tbody>tr"));
System.out.println("Total number of rows :"+ rows.size());
or using xpath
List<WebElement> rows = driver.findElements(By.xpath(".//table[@id='dummyTable']/tbody/tr"));
System.out.println("Total number of rows :"+ rows.size());