List<WebElement> links = driver.findElements(By.xpath("//*[@id=\"section56\"]/div[2]/div/div"));
int abcd = links.size();

Output = 1

Here because of the "::before",so I'm not able to count how many div's are there in the list

enter image description here

  • Is this meant to check behavior on your product? If not so, I would say this question is out-of-scope of SQA Exchange - more directed to Stack Overflow. Sep 13 at 13:46
  • @JoãoFarias Here is what my flow is >>> I want to count the number of div's in the red box, this count will change dynamically. Here in this example, there are 6 div's in the box, and I want this count of div's because I want to select the last-second div from this dynamic list. So to identify the last-second I want the size of the list, that how many records are there in the list >>> but because of this ::before I'm not able to count. So I want to know is there any way I can count with/without this ::before.
    – Dhairya
    Sep 13 at 20:28