Я создал задачу LoginToAuth0 для автоматизации и проверки входа моих сайтов в функциональность Auth0.
Моя цель - сделать отчет более понятным, а также подавить учетные данные для входа. Есть ли способ в Serenity объединить шаги и не быть настолько многословным (или это противоречит идее самой Serenity)?
Идеальный метод с параметром groupStepName был бы идеальным, если бы он предлагал опцию подавления отчетов о шагах в указанной группе.
public final void should(String groupStepName, Consequence... consequences) {...}
Возможно ли это? Также возможно ли сделать то же самое для воды?
Заранее спасибо,
Тим
public class LoginToAuth0 implements Task {
@Managed()
public WebDriver webDriver;
Actor actor;
public Auth0Site auth0Site;
private String email;
private String password;
protected LoginToAuth0(String email, String password) {
this.email = email;
this.password = password;
}
@Override
public <T extends Actor> void performAs(T actor) {
givenThat(actor).should(eventually(seeThat(auth0Site.isPage())),
eventually(seeThat(the(Auth0Site.loginContainer()), isCurrentlyVisible())),
eventually(seeThat(the(Auth0Site.emailField()), isCurrentlyVisible())),
seeThat(the(Auth0Site.passwordField()), isCurrentlyVisible()),
seeThat(the(Auth0Site.submitButton()), isCurrentlyVisible()));
when(actor).attemptsTo(Enter.theValue(email).into(Auth0Site.emailField()), new EnterPassword(),
Click.on(Auth0Site.submitButton()));
then(actor).should(eventually(seeThat(auth0Site.isPage(), not(true))));
}
public static class Builder {
private String email = null;
private String password = null;
public Builder withCredentials(String email, String password) {
this.email = email;
this.password = password;
return this;
}
public LoginToAuth0 build() {
if (this.email == null || this.password == null)
throw new IllegalStateException();
return Tasks.instrumented(LoginToAuth0.class, email, password);
}
}
private class EnterPassword extends SilentPerformable {
@Override
public <T extends Actor> void performAs(T actor) {
actor.attemptsTo(Enter.theValue(password).into(Auth0Site.passwordField()));
}
}
}