package cz.moneta.test.harness.support.web;

import cz.moneta.test.harness.context.StoreAccessor;
import cz.moneta.test.harness.endpoints.WebEndpoint;

/**
 * This ss the marker interface of web flow builder proxies.
 * <p/>
 * The builders are usually accessed via {@code harness.withIB()} or similar method where the proxy
 * is instantiated by calling the respective
 * {@link Builders#newWebFlowBuilder(Class, WebEndpoint, StoreAccessor)} method.
 * <p/>
 * An example web flow builder may look as follows:
 * <pre>{@code
 * @literal @Wait(value = {USERNAME_INPUT, PASSWORD_INPUT, CONFIRM_BUTTON})
 *  public interface LoginPage extends WebFlow<LoginPage>, LoginPageTransitions {
 *
 *      String USERNAME_INPUT = "//input[@tabindex='1' and @type='password']";
 *      String PASSWORD_INPUT = "//input[@tabindex='2' and @type='password']";
 *      String CONFIRM_BUTTON = "//button[@onclick='javascript:loginUser();']";
 *
 *     @literal @TypeInto(USERNAME_INPUT)
 *      LoginPage typeUsername(String username);
 *
 *     @literal @TypeInto(PASSWORD_INPUT)
 *      LoginPage typePassword(String password);
 *
 *     @literal @Click(CONFIRM_BUTTON)
 *      LoginPageTransitions clickLogin();
 *  }
 * }</pre>
 * Please note that if the return type of the method is a different WebFlow builder, a new proxy is instantiated
 * based on the return type
 * <p/>
 * And the usage would be as follows:
 * <pre>{@code
 *  harness.withIB()
 *      .openLoginPage()
 *      .typeUsername(udebsCredentials.getUsername())
 *      .typePassword(udebsCredentials.getPassword())
 *      .clickLogin()
 *      .onAuthMobileKeyPage()
 *      .fillMobileKey("12341234")
 *      .clickLogin()
 *      .onWelcomePage()
 *      ...
 * }</pre>
 *
 * @see Click
 * @see TypeInto
 * @see Select
 * @see CheckElementContent
 * @see CheckElementPresent
 * @see CustomAction
 * @see ExecuteJavaScript
 * @see FileUpload
 * @see GetCookie
 * @see GetElementContent
 * @see StoreElementContent
 * @see SwitchToFrame
 * @see Log
 * @see Wait
 * @see WaitOrFailOnErrorElement
 */
public interface WebFlow<A extends WebFlow<A>> extends Builder {
    void beforePageLoad(WebEndpoint endpoint);
}
