I am implementing Serenity BDD to build an automation suite for a product. I want to be able to find elements by xpaths which will be evaluated during run time.
For example, I want something like:
@FindBy(label="First Name")
private WebElementFacade firstNameTextBox;
Finding an element by label 'First Name' will be the same as finding it by xpath
".//div[(contains(@class,'mdr_label mdr_caption') or contains(@class,'fieldItemLabel')) and contains(.,'First Name')]/following-sibling::div//input"
I don't want to really repeat this long xpath in every declaration. I use the Dojo framework and so I have no other locators to get these elements other than by xpaths.
So, how do I add a custom FindBy
type?