Annotation Type Page


  • @Target(FIELD)
    @Retention(RUNTIME)
    public @interface Page
    Mark a field as a Page Object that should be automatically created by FluentLenium.
     @PageUrl("/")
     public class Homepage extends FluentPage {
    
          //@FindBy annotated elements
          //...
     }
    
     public class HomepageTest extends FluentPage {
    
          @Page
          Homepage homepage;
    
          //Homepage is instantiated and can be used by test methods.
     }
     

    If you are using Cucumber, it is not just page object classes but also step definitions classes that can be instantiated and injected using this annotation.

    Although injecting step definitions classes into other step definitions classes might not be the best approach, it is still achievable using this annotation if needed.

     public class LoginSteps extends FluentCucumberTest {
    
         @Given("a(n) {} user logged in")
         public void aUserLoggedIn(User user) {
             //login logic
         }
     }
    
     public class HomepageSteps extends FluentCucumberTest {
    
          @Page
          Homepage homepage;
          @Page
          LoginSteps loginSteps;
    
          @Given("{} user does stuff")
          public void userDoesStuff(User user) {
              loginSteps.aUserLoggedIn(user);
              //does some stuff
          }
     }