One of the challenges I'm facing in automating my application using Selenium webdriver is selecting the third web element on my page with a span tag and class name of 'nav-label'. While I can easily achieve this using XPath, I am curious to know if there is a CSS equivalent selector available.
Here is an example of the webelement in question:
<span class="nav-label">sometext</span>
After inspecting the elements with css=.nav-label
, I discovered that there are 3 matching elements. Now, my task is to select the third one specifically. Is it possible to do this using CSS selectors?
Currently, I can achieve the desired result using XPath like so: (//span[@class='nav-label'])[3]
I am eager to find out if there is a CSS equivalent for the XPath method described above.