2

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?

trancedjs
  • 43
  • 6
  • Seems a solution would be extending most of `net.serenitybdd.core.annotations` classes/interfaces/enums and concatenating your xpath expression with whatever parameter you provide. Have you tried this? – JDelorean Aug 19 '16 at 11:53
  • The answer to your question is right here: http://stackoverflow.com/questions/24251739/selenium-webdriver-page-factory-initialization-using-paths-relative-to-other-el – JDelorean Aug 23 '16 at 12:47

0 Answers0