Description
Used to hold common actions which might be required in different contexts. If you have for example multiple pages sharing the same functionality we advice you to rather create a parent PageObject which will hold it rather than using Logic class.
Usage
Traditional example is login. See this example:
public class UserLogic extends Logic {
public UserExtraPage login(String login, String password) {
if (!isAt(BaseLayoutPage.class)) goTo(HomePage.class);
return getPage(HomePage.class).login(login, password);
}
}
Assuming that you have previously created BaseLayoutPage containing method for login and HomePage is its child, you can then call snippet below from anywhere in your test to login:
seb.initLogic(UserLogic.class).login("user", "password")
Seb will first evaluate if you are on any subclass of BaseLayoutPage. If not, it will navigate to Homepage and login.