Open Jacobvu84 opened 3 years ago
import net.serenitybdd.screenplay.Actor;
import net.serenitybdd.screenplay.Question;
import net.serenitybdd.screenplay.abilities.BrowseTheWeb;
import net.serenitybdd.screenplay.questions.Text;
import static net.serenitybdd.screenplay.questions.ValueOf.the;
public class Advertisement implements Question<AdvertisementInfor> {
@Override
public AdvertisementInfor answeredBy(Actor actor) {
String title = BrowseTheWeb.as(actor).getTitle();
String sponsor = the(Text.of(SPONSOR).viewedBy(actor));
String adType = the(Text.of(AD_TYPE).viewedBy(actor));
return new AdvertisementInfor(title, sponsor, adType);
}
public static Advertisement information() {
return new Advertisement();
}
}
import static net.serenitybdd.screenplay.GivenWhenThen.*;
import static net.serenitybdd.screenplay.matchers.ConsequenceMatchers.displays;
import static org.hamcrest.Matchers.containsString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.core.Is.is;
@Test
public void should_be_able_to_identify_the_advertisement() {
.............
jacob.should(
seeThat(Advertisement.information(),
displays("Title",equalTo("Quần áo trẻ em")),
displays("Sponsor",equalTo("Gấu Gấu Shop")),
displays("Ad Type", containsString("Image"))
)
);
}