Our Devs are using data-auto-id within the latest project
- makes my scripting hard and
- selenium does not recognise it as an ID unfortunately.
Can anyone tell me how in my POM i can identify data-auto-id within C#/.NET without a huge code overhead.
Currently I am writing my POM as per below, so if we can stick to this format that would be great.
public IWebElement PWReset { get { return _driver.FindElement(By.CssSelector("CSS Data here, too long to post")); } }
HTML for this example
<div data-auto-id="Password_Reset" class="StyledForgotPasswordLabel-sc-gxihsg jmrJqH">Forgotten your password?</div>
Code to Guys Suggestion
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
public IWebElement PWReset { get { return _driver.FindElement(By.CssSelector("[data-auto-id='Password_Reset']")); } }
Error being produced is as follows: OpenQA.Selenium.NoSuchElementException: 'no such element: Unable to locate element: {"method":"css selector","selector":"[data-auto-id='Password_Reset']"} (Session info: chrome=77.0.3865.90)'