Trying to use By.cssSelector to capture the nth dom element with class c3 in a structure similar to this:
<div class="c1">
<div class="c2">
<div class="c3">...</div>
</div>
</div>
<div class="c1">
<div class="c2">
<div class="c3">...</div>
</div>
</div>
<div class="c1">
<div class="c2">
<div class="c3">...</div>
</div>
</div>
Struggling with CSS selector testing, particularly when using pseudo-class :nth-of-type()
.
This selector works for the 2nd instance of c2/c3:
.c1:nth-of-type(2)
However, the following do not select anything:
.c2:nth-of-type(2)
.c3:nth-of-type(2)
In Selenium, these selectors also yield no results. While there are other ways to identify these elements (such as XPATH), understanding :nth-of-type()
continues to be a challenge. Seeking insights on why the latter two selectors fail or clarification on the usage of this pseudo-class.
Encountering this issue on Chrome (29/30) and Firefox (24/25).