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

import java.lang.annotation.ElementType;
import java.lang.annotation.Repeatable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * Checks if element is present, if not TimeoutException is thrown. <br>
 * Dynamic path functionality is supported. See {@link cz.moneta.test.harness.support.web.DynamicPathPart}
 * for use or open  @see <a href="https://confluence.moneta.cz/display/CONT/Dynamic+Elements">Confluence Best Practises page</a><br>
 * <u>Example:</u>
 * <pre>
 *        {@literal @}CheckElementPresent (SOME_VALUE)
 *          SomePage someElement();
 *    </pre>
 * {@link #by()} can be used when there is need to use other than default lookup function.<br>
 * {@link #isStringDynamicXpath()} - Use to set String from method in xpath. Boolean type. The default value is: false.<br>
 *
 * <u>Example2:</u>
 * <pre>
 *        {@literal @}CheckElementPresent (value = SOME_XPATH_VALUE,
 *                                         by = Lookup.XPATH)
 *          SomePage someElement();
 *    </pre>
 * {@link #by()} could be used for other then default type of element search.
 * <u>Example3:</u><br>
 * <pre>
 *         {@literal @}CheckElementPresent{
 *               value = SOME_XPATH,
 *               by = Lookup.XPATH,
 *          )
 *          SomePage someElement();
 *    </pre>
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(CheckElementsPresent.class)
public @interface CheckElementPresent {

    /**
     * Value for element identification.
     */
    String value();

    /**
     * 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.
     */
    boolean isStringDynamicXpath() default false;
}