@Test
public void items_related_to_login_should_be_displayed() {
givenThat(anna).wasAbleTo(Start.onTheSignInPage());
andThat(anna).wasAbleTo(
Login.with("abc", "abc")
);
when(anna).attemptsTo(
openPage1,
Scroll.to(By.className("foo"))
);
then(anna).should(eventually(seeThat(TheWebPage.title(), containsString("some text"))));
when(anna).attemptsTo(
openPage2,
Scroll.to(By.className("foo"))
);
then(anna).should(eventually(seeThat(TheWebPage.title(), containsString("some text"))));
}
WebElement login = element(By.cssSelector("#login"));
new Actions(getDriver()).moveToElement(login).build().perform();
public class TheWatchedHistory implements Question<String> {
@Override
public String answeredBy(Actor actor) {
Scroll.to(WatchedHistoryItem.HEADING).performAs(actor);
return Text.of(WatchedHistoryItem.HEADING).viewedBy(actor).asString();
}
public static Question<? extends String> text() {
return new TheWatchedHistory();
}
}
Hi Ilyas,
To scroll to a point, you would just invoke the Scroll class, e.g.
actor.attemptsTo(Scroll.to(WatchedHistoryItem.HEADING))
You wouldn’t normally call the performAs() method directly.
It would also be unusual to perform an action inside a Question (Questions are meant to be read-only and as idempotent as possible).
I assume it’s because you are experimenting, but the code in the test does look quite low level - normally you wouldn’t have UI interactions directly at the test level when you use the ScreenPlay pattern; rather the test would only contain business tasks that describe what the user is doing in business terms, not in terms of UI interactions.
It would also be unusual to have "when..then..when..then", as ScreenPlay encourages tests to describe the behaviour and expected outcome of a single acceptance criteria in each test (like well-written BDD scenarios). So the scenario might look something like this:
givenThat(anna).wasAbleTo(LoginToTheApplication.asANormalCustomer());
when(anna).attemptsTo(
ViewTheCatologItems.forCategory(“foo”)
);
then(anna).should(eventually(seeThat(TheCatalog.title(), containsString("All Things Foo"))));
}
--
You received this message because you are subscribed to the Google Groups "Serenity BDD Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to thucydides-use...@googlegroups.com.
To post to this group, send email to thucydid...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.