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;

/**
 * This assertion saves a key-value pair obtained from site by using particular lookup method (e.g. XPath).
 * Key and lookup_value strings are mandatory, lookup_method is optional.<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 @}StoreElementContent (key_name, value_lookup)
 *           SomePage goToPageOrWhatever();
 *     </pre>
 * {@link #by()} can be used for use XPATH, ID or DEFAULT to identify element.<br>
 * {@link #isStringDynamicXpath()} - Use to set String from method in xpath. Boolean type. The default value is: false.<br>
 * <u>Example2:</u><br>
 * <pre>
 *          {@literal @}StoreElementContent (key_name, value_lookup, lookup_method)
 *                key_name = KEY_NAME,
 *                lookup_value = SOME_XPATH,
 *                lookup_method = Lookup.XPATH,
 *           )
 *           SomePage goToPageOrWhatever();
 *     </pre>
 */

@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(StoreElementContents.class)
public @interface StoreElementContent {

    /**
     * A unique key under which is the value stored.
     */
    String storeKey();

    /**
     * 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;
}