Annotation Interface Label
FluentWebElement
or
FluentList
.
By default the injected element's original toString()
value is returned but with
having the @Label
annotation with different configurations that toString value can
be overridden. Using it can provide more meaningful error messages during test execution and
debugging.
FluentWebElement
Examples:
public class HomepageHeader { @FindBy(css = "#header") private FluentWebElement header; //toString(): By.cssSelector: #header (first) (Lazy Element) @FindBy(css = "#header") @Label private FluentWebElement headerDefaultLabel; //toString(): HomepageHeader.headerDefaultLabel (Lazy Element) @FindBy(css = "#header") @Label("customLabel") private FluentWebElement headerCustomLabel; //toString(): customLabel (Lazy Element) }
FluentList
Examples:
public class HomepageHeader { @FindBy(css = ".footer-link") private FluentList<FluentWebElement footerLinks; //toString(): By.cssSelector: .footer-link (<toString() of the underlying list of FluentWebElements) @FindBy(css = ".footer-link") @Label private FluentList<FluentWebElement footerLinksDefaultLabel; //toString(): HomepageHeader.footerLinksDefaultLabel (<toString() of the underlying list of FluentWebElements) @FindBy(css = ".footer-link") @Label("customLabel") private FluentList<FluentWebElement footerLinksCustomLabel; //toString(): customLabel (<toString() of the underlying list of FluentWebElements) }
This annotation is independent from the LabelHint
annotation. Each one can be used without the other.
Defining a label can also be done inline on an a FluentWebElement
or FluentList
by calling the withLabel()
method on it.
-
Optional Element Summary
-
Element Details
-
value
String valueLabel value.If not defined, it will use the class name and field name as the label.
- Returns:
- label value
- Default:
- ""
-