selemium get number of elements code example
Example: count objects in selenium java
int xpathCount = webDriver.findElements(By.xpath("Valid_Xpath")).size();
int xpathCount = webDriver.findElements(By.xpath("Valid_Xpath")).size();