Skip to content

Instantly share code, notes, and snippets.

@asolntsev
Last active May 1, 2020 15:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asolntsev/bf4b0ac648c50ed6dfdaf334a6f36912 to your computer and use it in GitHub Desktop.
Save asolntsev/bf4b0ac648c50ed6dfdaf334a6f36912 to your computer and use it in GitHub Desktop.
import com.codeborne.selenide.SelenideElement;
import org.junit.jupiter.api.Test;
import static com.codeborne.selenide.CollectionCondition.size;
import static com.codeborne.selenide.Selectors.byText;
import static com.codeborne.selenide.Selenide.$;
import static com.codeborne.selenide.Selenide.$$;
public class PageObjectWithoutContainersTest {
@Test
void containersUsage() {
HistoryPage page = new HistoryPage();
page.shouldHaveRecords(8);
page.record(1).status().shouldHave(text("Booked"))
page.showMore();
page.shouldHaveRecords(42);
page.record(41).status().shouldHave(text("Overbooked"))
}
static class HistoryPage {
public void showMore() {
$(byText("SHOW MORE")).click();
}
public void shouldHaveRecords(int expectedRecordsCount) {
$$("div[id^='bookingRef-']").shouldHave(size(expectedRecordsCount));
}
public BookingRecord record(int index) {
return new BookingRecord($("div[id^='bookingRef-']", index));
}
}
static class BookingRecord {
private final SelenideElement container;
public BookingRecord(SelenideElement container) {
this.container = container;
}
public SelenideElement pickupTime() {
return container.$("div[id^='bookingPickupTime-']");
}
public SelenideElement status() {
return container.$("span[id^='bookingStatusTag-'] > span");
}
public void openRecord() {
container.$("img[id^='bookingId-']").click();
}
}
}
@asolntsev
Copy link
Author

asolntsev commented Apr 22, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment