In our current automation (using Selenium/WebDriver/Java), we use @FindBy
very extensively. For example:
@FindBy(css="a[name='bcrumb']") protected List<WebElement> breadCrumbLinks;
@FindBy(id="skuError") protected WebElement skuError;
@FindBy(className="reducedPrice") protected List<WebElement> reducedPrice;
@FindBy(partialLinkText="Injinji RUN 2.0") protected WebElement playButton;
@FindBy(linkText="annual member refund") protected WebElement annualMemberRefund;
@FindBy(xpath="//li[@itemprop='price']") protected WebElement productPrice;
By definition, @FindBy
can locate a selector using the following: using, id, name, className, css, tagName, linkText, partialLinkText and xpath.
Recently, our front-end devs proposed that we implement an new attribute class that begins with 'test='. I think this is a great idea since we could find WebElements by just looking for that blurb of text, rather than the values that @FindBy
inherently uses. My question is, would it be better to extend the existing functionality of @FindBy
OR, create a new way of searching for the WebElements we use in our tests?