0

How do we locate both Data QA Id and CSS Class using Selenium C# ?

We're trying to locate both a DataQAid attribute and also see if its class ng-invalid, (Angular Material Textbox Error)

This is what wrote so far:

private By PhoneError => By.XPath("//*[@attr.data-qa='homephone']");

enter image description here

Resource: https://stackoverflow.com/questions/24120263/find-element-in-selenium-using-xpath-or-css-selector

4
  • is your locator working ? why are using @attr.data-qa instead of @data-qa
    – PDHide
    Aug 13 '20 at 8:37
  • 1
    Why do you use 'homephone' when the value is 'homephone-update' ? Aug 13 '20 at 10:01
  • @NielsvanReijmersdal are you aware of attr.data-qa ? Is it something new or even that is wrong . I never seen such a usage .
    – PDHide
    Aug 13 '20 at 10:13
  • 1
    @PDHide No, I think it is a miss interpretation of examples Aug 13 '20 at 17:30
1
By.XPath("//*[@data-qa='homephone-update' and @class='ng-invalid']");

Try this

2
  • This answers the how to use both attr and class. I do not think it solves the issue of the OP, as the data-qa field is homephone-update. Aug 13 '20 at 10:01
  • @NielsvanReijmersdal thanks Niel i updated it , i didnt notice the remainingg
    – PDHide
    Aug 13 '20 at 10:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.