info.novatec.testit.webtester.pagefragments.annotations.PostConstructMustBe Maven / Gradle / Ivy
package info.novatec.testit.webtester.pagefragments.annotations;
import info.novatec.testit.webtester.conditions.Condition;
import info.novatec.testit.webtester.conditions.Conditions;
import info.novatec.testit.webtester.conditions.pagefragments.Disabled;
import info.novatec.testit.webtester.conditions.pagefragments.Editable;
import info.novatec.testit.webtester.conditions.pagefragments.Enabled;
import info.novatec.testit.webtester.conditions.pagefragments.Interactable;
import info.novatec.testit.webtester.conditions.pagefragments.Invisible;
import info.novatec.testit.webtester.conditions.pagefragments.Present;
import info.novatec.testit.webtester.conditions.pagefragments.PresentAndVisible;
import info.novatec.testit.webtester.conditions.pagefragments.ReadOnly;
import info.novatec.testit.webtester.conditions.pagefragments.Selected;
import info.novatec.testit.webtester.conditions.pagefragments.Visible;
import info.novatec.testit.webtester.pagefragments.PageFragment;
import info.novatec.testit.webtester.pages.Page;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Identification methods of {@link Page pages} and {@link PageFragment page fragments} can be annotation with this
* annotation. Doing so will trigger an automatic post construct check on the page / page fragment after it's
* initialization. This check will take the {@link PostConstructMustBe @PostConstructMustBe's} condition and evaluate it.
*
* Important: The used condition class must provide a default constructor! Hence not all of our provided {@link
* Conditions} will work. The following conditions can be used:
*
* - {@link Disabled}
* - {@link Editable}
* - {@link Enabled}
* - {@link Interactable}
* - {@link Invisible}
* - {@link Present}
* - {@link PresentAndVisible}
* - {@link ReadOnly}
* - {@link Selected}
* - {@link Visible}
*
*
* Example:
*
* // this will throw an exception if the username is not visible when the page is initialized
* @PostConstructMustBe(Visible.class)
* @IdentifyUsing("#username")
* TextField username();
*
* // in cases where fragments are created using JavaScript an additional wait can be defined in the following way:
* @PostConstructMustBe(Visible.class)
* @WaitUntil(Present.class)
* @IdentifyUsing("#username")
* TextField username();
*
*
* @see Condition
* @see Conditions
* @since 2.0
*/
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface PostConstructMustBe {
/**
* The {@link Condition} condition to use for the must check.
*
* @return the condition to use
* @since 2.0
*/
Class value();
}