1

I have building my Selenium framework. All the elements need to be found by Data-QA. I am unsure on how to do this. I have done the pervious using Ids that was simple enough. I cannot find data qa in the find element by

Would anyone be able to point me in the right direction.

5
  • what is "Data-QA" ? Commented Jan 24, 2019 at 18:12
  • So if I inspect the object <input _ngcontent-c1="" class="mat-input-element mat-form-field-autofill-control cdk-text-field-autofill-monitored ng-pristine ng-invalid ng-touched" data-qa="'input_login_operator'" id="login-operator-field" matinput="" name="operator" placeholder="Operator" required="" aria-invalid="true" aria-required="true" aria-describedby="mat-error-0"> Commented Jan 24, 2019 at 18:16
  • also for ref: utest.com/articles/… Commented Jan 24, 2019 at 18:18
  • Post an example of your mark-up. Your question will likely get closed without it. Commented Jan 24, 2019 at 19:14
  • Forgive me. Mark-up? Commented Jan 24, 2019 at 20:09

2 Answers 2

1

It looks like you are attempting to find elements with a particular value for a specific attribute. I don't know C#, but with Python the following should work (I like to use a CSS selector):

all_login_inputs = find_elements_by_css_selector("input[data-qa='input_login_operator']")

this will return a list of elements that have a tag "input" with the "data-qa" attribute set to the value "input_login_operator"

Sign up to request clarification or add additional context in comments.

4 Comments

If my short experience is correct I should be using driver.FindElement(By.CssSelector("input[data-qa='input_login_operator']"); I will try tomorrow, thanks. If anyone else can confirm or deny that would be great.
This didn't work. I have also tried [FindsBy(How = How.CssSelector, Using = "data-qa=input_login_operator")] public IWebElement txtOperator { get; set; }
please update your question (not as comments) with the relevant HTML code, your selenium code, and the exception stack trace that shows up when it doesn't work. These are the details that will allow us to help you.
Sorted FindElement(By.cssselector(input[data-qa=input_login_operator])
0

It looks like there are extra single quotes in the HTML, inside the double quotes:

data-qa="'input_login_operator'"

I would remove the single quotes from the DOM, or escape them in the CSS selector.

Comments

Your Answer

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.