Junior — Middle
Milline disainimuster on automaattestimises kõige olulisem pärast Page Object mustrit?
sobes.tech AI
Vastus AI-lt
After the Page Object pattern, one of the most significant design patterns in automated testing is the "Screenplay" (or "Actor Pattern") pattern.
It extends the idea of Page Object by focusing on the actions (tasks) performed by the user (actor), rather than just on the structure of pages. This improves the readability and reusability of tests.
Example of using Screenplay:
// The actor performs a task
actor.attemptsTo(Login.withCredentials("user", "pass"));
// The task describes actions
public class Login implements Task {
private String username;
private String password;
public static Login withCredentials(String user, String pass) {
return new Login(user, pass);
}
public void performAs(Actor actor) {
actor.attemptsTo(
Enter.theValue(username).into(USERNAME_FIELD),
Enter.theValue(password).into(PASSWORD_FIELD),
Click.on(LOGIN_BUTTON)
);
}
}
This pattern helps create more modular and understandable tests.