I want to count some tags in this page Link
I am trying to count the tags of opening positions so, I tried this code using java to count but I always find my count is = 0;
public By cardsNumOfPositions = By.xpath("//div[@class='card']");
List<WebElement> element = driver.findElements(cardsNumOfPositions);
int countelements = element.size();
And I write this function to count:-
public void printCountElements() {
System.out.println(countelements);
}
Everytime the count is 0, I searched for an Iframe but I didn’t find any. so how can I get the size of this element?
Advertisement
Answer
Also, you can make countelements as a static variable.
like this:
static int countelements;
now since it’s static, its value will persist. You can call it like this:
public void printCountElements() {
countelements = element.size();
System.out.println(countelements);
}