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.

Chris Birch
  • 41
  • 2
  • 7

2 Answers2

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"

Breaks Software
  • 1,721
  • 1
  • 10
  • 15
  • 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. – Chris Birch Jan 24 '19 at 19:07
  • 1
    This didn't work. I have also tried [FindsBy(How = How.CssSelector, Using = "data-qa=input_login_operator")] public IWebElement txtOperator { get; set; } – Chris Birch Jan 25 '19 at 08:03
  • 1
    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. – Breaks Software Jan 25 '19 at 12:03
  • Sorted FindElement(By.cssselector(input[data-qa=input_login_operator]) – Chris Birch Jan 25 '19 at 18:47
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.

pirsqua
  • 346
  • 1
  • 2
  • 12