Package org.fluentlenium.core.annotation
Annotation Type Label
-
@Retention(RUNTIME) @Target(FIELD) public @interface Label
Define a label on an injectedFluentWebElement
orFluentList
.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
orFluentList
by calling thewithLabel()
method on it.
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.String
value
Label value.
-