Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 99418

How do you find an data-auto-id

$
0
0

Our Devs are using data-auto-id within the latest project

  1. makes my scripting hard and
  2. 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)'


Viewing all articles
Browse latest Browse all 99418

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>