3

I am currently learning page object model (POM) and I am trying to access a specific web element using @FindBy but I am not sure how to correctly write the syntax for my element into @FindBy?

What I have is:

driver.findElement(By.cssSelector("a[dta-qid='inventory']");

So my question is how do I place a[da-qid='inventory'] correctly into @FindBy?


Edit:

By, a[da-qid='inventory'], what I mean is that it selects every <a> element whose da-qid value begins with 'inventory'.

2
@FindBy(css="a[dta-qid='inventory']")

I've used that kind of locators in my last project and it's worked like charm. I hope this is that You want :)

  • Awesome, thanks! This is what I was look for. – Robben Jul 23 '15 at 20:31
0

I can't give you an exact answer without seeing the full element, but the official documentation on selectors ought to help you out.

0

This syntax might help u check out. @FindBy(locator="locator value") private WebElement elementName; Don't forget in POM we follow encapsulation concept

  • Hi @Anand welcome to SQA, We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed. – Bruce McLeod Jul 27 '15 at 4:07

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.