How to count the number of elements are matching with for the given xpath expression
xpath: driver.findElement(By.xpath(\"//div[contains(@id,\'richedittext_insta
Another option If you are basing your requirements strictly on the need to use Selenium, you might be able to do something like this using WebElements and getting the size of the returned list:
List myListToCheck=currentDriver.findElements(By.xpath("somePath"));
if(myListToCheck.size()>0){
//do this
}else{
//do something else
}
Or just simply returning the size of the returned list; if that's all you really want to get from it...
int mySize=myListToCheck.size()
I believe once you have an established WebElements list, you can also use iterators to go over that list. Helpful, I dunno... just providing another way to get to the same end-game.