Page Factory @FindBy

Robben picture Robben · Jul 23, 2015 · Viewed 13.2k times · Source

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?


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

Answer

Saifur picture Saifur · Jul 23, 2015

Why do not you read through this? Use of @FindsBy is easier if you do that with How Enum. You have multiple options in that case. With cssSelector it should look like this

@FindBy(how = How.css, using = "a[dta-qid='inventory']") 
WebElement foobar;