As of now I am getting the count of the number of matching results using listChanges.size()
. How do I directly get the count without loading getChanges
in the list?
By getChanges = By.xpath("//td[contains(@class,'blob-code blob-code-addition') or contains(@class,'blob-code blob-code-deletion')]");
List<WebElement> listChanges = driver.findElements(getChanges);
I found this(Count function in XPath) and I tried the below which does not work!
Integer getCount = By.xpath(count("//td[contains(@class,'blob-code blob-code-addition') or contains(@class,'blob-code blob-code-deletion')]"));
Looks like I have to do something like this.
Integer getCount = By.xpath("count(//td[contains(@class,'blob-code blob-code-addition') or contains(@class,'blob-code blob-code-deletion')])");
But the right hand side returns an object of type By