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

import java.lang.annotation.*;

/**
 * TypeInto annotation is used for write some value to element.<br>
 * This annotation does not support dynamic path construction.<br>
 * <u>Example:</u>
 *    <pre>
 *        {@literal @}TypeInto (SOME_VALUE)
 *         SomePage fillElement(String text);
 *    </pre>
 * Element can be cleared before write using {@link #clear()}.<br>
 * {@link #jsType()} is available when standard typeInto not works. <br>
 * {@link #andWait()} is used for wait to other element after fill. <br>
 * <u>Example2:</u>
 *    <pre>
 *          {@literal @}TypeInto{
 *             &emsp;value = SOME_VALUE,
 *             &emsp;clear = true,
 *             &emsp;andWait = @Wait(forXpath = "xpath of element to wait", waitSecondsForElement = 50),
 *             &emsp;jsType = true
 *           )
 *           SomePage fillElement(String text);
 *    </pre>
 * {@link #by()} could be used for other then default type of element search.
 * <u>Example3:</u><br>
 *    <pre>
 *         {@literal @}TypeInto{
 *               value = SOME_XPATH,
 *               by = Lookup.XPATH,
 *          )
 *          SomePage fillElement(String text);
 *    </pre>
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(TypeIntos.class)
public @interface TypeInto {
    /**
     * Value for identification of element. XPATH or ID of element can be used.
     */
    String value();

    /**
     * Set true if want to use javascript Type into element instead of Selenium.
     */
    boolean jsType() default false;

    /**
     * Set true if want to clear element before write.
     */
    boolean clear() default false;

    /**
     * Wait for element show after typing. Use {@literal @}{@link Wait} annotation. Tool is not waiting for any element by default.
     */
    Wait andWait() default @Wait;

    /**
     * Type of element identification which will be used for element search. XPATH, ID or DEFAULT can be used.
     * @see Lookup
     */
    Lookup by() default Lookup.DEFAULT;

    /**
     * If set true will be used input String parameter of method to substitute %s in xpath. In container of method with TypeInto annotation you must have everywhere use just normal xpath or dynamic xpath!
     */
    boolean isStringDynamicXpath() default false;
}
