When automating a website with Selenium C#, I encountered a NoSuchElementException when trying to click an element using a CSS selector. However, the issue was resolved when using xpath instead. Can someone shed light on why this discrepancy between CSS and xpath selectors?
Xpath value:
//*[@id="primary-navigation"]/ul/li[2]/a
CSS Selector value:
#primary-navigation > ul > li:nth-child(2) > a