Another option If you base your requirements strictly on the need to use Selenium, you can do something similar using WebElements and get the size of the returned list:
List<WebElement> myListToCheck=currentDriver.findElements(By.xpath("somePath")); if(myListToCheck.size()>0){ //do this }else{ //do something else }
Or just simply return the size of the returned list; if that's all you really want to get from him ...
int mySize=myListToCheck.size()
I believe that if you have an installed list of WebElements, you can also use iterators to navigate this list. Useful, I donβt know ... just provide another way to get to the same final game.
ronsky
source share