I have couple of pages that have similar structure, similar elements. But selectors are different from the first tag.
Selector for the element on one page:
@FindBy(xpath = "//picture-item//div[@class='files']/button") private WebElement deleteButton;
Selector for the element on another page:
@FindBy(xpath = "//doc-item//div[@class='files']/button") private WebElement deleteButton;
I want to have an abstract class, which would have all common elements and each page would extend abstract class, but in the beginning of the selector would use its own tag (picture-item or doc-item).
How to do it, because FindBy doesn't support dynamic locators?
Probably, you would recommend to use following locator in abstract class and don't add any tag in the beginning on some page:
@FindBy(xpath = "//div[@class='files']/button") private WebElement deleteButton;
But it doesn't work in this way. Because web-site is a single page application and all locators are available, when application is loaded. So, if using this locator I would get a lot of deleteButton elements.