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

asked Aug 12, 2020 at 20:03
4
  • is your locator working ? why are using @attr.data-qa instead of @data-qa Commented Aug 13, 2020 at 8:37
  • 1
    Why do you use 'homephone' when the value is 'homephone-update' ? Commented Aug 13, 2020 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 . Commented Aug 13, 2020 at 10:13
  • 1
    @PDHide No, I think it is a miss interpretation of examples Commented Aug 13, 2020 at 17:30

1 Answer 1

1
By.XPath("//*[@data-qa='homephone-update' and @class='ng-invalid']");

Try this

answered Aug 13, 2020 at 8:37
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. Commented Aug 13, 2020 at 10:01
  • @NielsvanReijmersdal thanks Niel i updated it , i didnt notice the remainingg Commented Aug 13, 2020 at 10:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.