@@ -0,0 +1,2071 @@
+package ch.skymarshall.tcwriter.pilot.selenium;%0A%0Aimport java.time.Duration;%0Aimport java.util.function.Consumer;%0Aimport java.util.function.Function;%0A%0Aimport org.openqa.selenium.WebElement;%0Aimport org.openqa.selenium.WrapsElement;%0Aimport org.openqa.selenium.support.PageFactory;%0A%0Aimport ch.skymarshall.tcwriter.pilot.EditionPolling;%0Aimport ch.skymarshall.tcwriter.pilot.Polling;%0A%0Apublic class PagePilot%3CT%3E %7B%0A%0A%09private Class%3CT%3E pageClass;%0A%09private SeleniumGuiPilot pilot;%0A%09private T page;%0A%0A%09public PagePilot(SeleniumGuiPilot pilot, Class%3CT%3E pageClass) %7B%0A%09%09this.pilot = pilot;%0A%09%09this.pageClass = pageClass;%0A%09%7D%0A%0A%09public T page() %7B%0A%09%09return loadPage();%0A%09%7D%0A%0A%09public ElementPilot element(Function%3CT, WebElement%3E toElement) %7B%0A%09%09return new ElementPilot(pilot) %7B%0A%09%09%09@Override%0A%09%09%09protected WebElement loadGuiComponent() %7B%0A%09%09%09%09WebElement webElement = toElement.apply(loadPage());%0A%09%09%09%09if (((WrapsElement) webElement).getWrappedElement() == null) %7B%0A%09%09%09%09%09return null;%0A%09%09%09%09%7D%0A%09%09%09%09return webElement;%0A%09%09%09%7D%0A%0A%09%09%09@Override%0A%09%09%09protected void invalidateCache() %7B%0A%09%09%09%09super.invalidateCache();%0A%09%09%09%09page = null;%0A%09%09%09%7D%0A%0A%09%09%09@Override%0A%09%09%09protected String getDescription() %7B%0A%09%09%09%09String result = super.getDescription();%0A%09%09%09%09if (result == null) %7B%0A%09%09%09%09%09result =  toElement.apply(loadPage()).toString();%0A%09%09%09%09%7D%0A%09%09%09%09return result;%0A%09%09%09%7D%0A%09%09%09%0A%09%09%09@Override%0A%09%09%09public String toString() %7B%0A%09%09%09%09return %22Element of page %22 + pageClass;%0A%09%09%09%7D%0A%09%09%7D;%0A%09%7D%0A%0A%09private T loadPage() %7B%0A%09%09if (page == null) %7B%0A%09%09%09page = PageFactory.initElements(pilot.getDriver(), pageClass);%0A%09%09%7D%0A%09%09return page;%0A%09%7D%0A%0A%09public %3CU%3E U wait(Function%3CT, WebElement%3E toElement, final Polling%3CWebElement, U%3E polling) %7B%0A%09%09return element(toElement).wait(polling);%0A%09%7D%0A%0A%09public boolean wait(Function%3CT, WebElement%3E toElement, Consumer%3CWebElement%3E action) %7B%0A%09%09return element(toElement).wait(EditionPolling.action(action).withName(%22%3Canonymous action%3E%22));%0A%09%7D%0A%0A%09public boolean ifEnabled(Function%3CT, WebElement%3E toElement, final Polling%3CWebElement, Boolean%3E polling,%0A%09%09%09final Duration shortTimeout) %7B%0A%09%09return element(toElement).ifEnabled(polling, shortTimeout);%0A%09%7D%0A%0A%7D%0A

Improve pilot api