browser – Selenium Webdriver – how to select element
I’m not sure how you got the XPath, but it does not look correct. Using the same code, I’ve got the XPath: //*[@id="page-header-navbar"]/div/div/div/div[2]/div/span
You can simply Open F12 Developer Tools –> Inspect the element –> Locate the element –> Right click on it –> Copy –> Copy XPath.
So it should be: driver.FindElement(By.XPath("//*[@id=\"page-header-navbar\"]/div/div/div/div[2]/div/span"));
Now I can get the element without any error message.
Read more here: Source link
