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 annotation is used when you need to press some keyboard keys on page.
 * You can add one or more keys to {@link #value()}. There is 100 ms delay between keys pressing by default if you want to
 * press keys in same time use {@link #chord()}.<br>
 * {@link #andWait()} is used when you want to wait for something after key press.<br>
 * <u>Example:</u>
 *    <pre>
 *         {@literal @}KeyPress (Key.END)
 *          SomePage scrollToPageEnd();
 *    </pre>
 * <u>Example2:</u>
 *    <pre>
 *         {@literal @}KeyPress ({Key.NUMBER_1, Key.NUMBER_2, Key.NUMBER_3})
 *          SomePage press123();
 *    </pre>
 * <u>Example3:</u>
 *    <pre>
 *         {@literal @}KeyPress (value = {Key.CONTROL, Key.A}, chord = true)
 *          SomePage selectAllContent();
 *    </pre>
 * <u>Example3:</u>
 *    <pre>
 *         {@literal @}KeyPress (
 *              value = Key.DOWN,
 *              andWait = {@literal @}Wait(value = XPATH, by = Lookup.XPATH),
 *          )
 *          SomePage pressEndAndWaitForSomething();
 *    </pre>
 */
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Repeatable(KeyPresses.class)
public @interface KeyPress {

    /**
     * One or array of Keys to be press
     * @see Key
     */
    Key[] value();

    /**
     * In default keys are pressed with 100ms delay. If you want to press keys at same time (for example CTRL+A) set to true
     */
    boolean chord() default false;

    /**
     * Wait for element after key press. See {@literal @}{@link Wait} annotation.
     */
    Wait andWait() default @Wait;
}
