My code can't find a registration link with XPath
. Same problem using CSSSelector
.
driver = new ChromeDriver(options);
driver.Navigate().GoToUrl("https://www.goldtoe.com/state/landing");
var LoginLink = driver.FindElement(By.XPath("//li[@class='hidden-xs myAccountMenu']//a[contains(text(),'Sign In/Register')] "));
LoginLink.Click();
Message:
> OpenQA.Selenium.NoSuchElementException : no such element: Unable to
> locate element: {"method":"xpath","selector":"//li[@class='hidden-xs
> myAccountMenu']//a[contains(text(),'Sign In/Register')] "} (Session
> info: chrome=74.0.3729.169) (Driver info: chromedriver=74.0.3729.6
> (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows
> NT 10.0.17763 x86_64)
I think you need an escape character for 'Sign In/Register' string, specifically for '/' special character. So, try 'Sign In\/Register' instead. Use '\' as the escape character.