I have trying to get the number of buttons(count) enabled in a web page using their class names. But I couldn't get it as I wanted. Always I get count as 0.
int count = 0;
try {
List<WebElement> Elements = driver.findElements(By.className(Locators.Buttons));
for (int Counter = 0; Counter < Elements.size(); Counter++) {
count = Counter;
}
System.out.print("############################################# " + count);
}
catch (Exception e)
{
}
return count;
I have declared xpath as follows
//button[class='btn btn--05 thm--01']
Other buttons have a class names starting like this. I tried using contains keyword. But didn't work.
Number of buttons enabled can be varied. Therefore buttons should be identified using above class name. How can I do it?
I have tried doing these examples too.
Similar question asked