I am building a selenium-based test application uses CSS Selectors or XPath strings, and am attempting to test menu items that appear on hover. Using "Inspect Element" in Chrome and in FireFox by right clicking, can verify that the right html is being highlighted, but when I copy the CSS Selector or the XPath, it sometimes selects multiple elements. For instance:
"#myId > li:nth-child(2) > a"
was what Chrome gave me, but it represents 13 elements in the DOM (each in a different sub-menu). The selector I need is the ninth element of the selector's result:
$("#myId > li:nth-child(2) > a")[9]
My main question is whether this can be represented as a CSS selector? I searched for an example but didn't find this particular problem.
$("#myId > li:nth-child(2) > a(9)")
Does not work - returns empty array.
> a:nth-child(9)
– Blazemonger 2 days ago