1 package com.atlassian.pageobjects.elements;
2
3 import com.atlassian.pageobjects.elements.timeout.TimeoutType;
4
5 import java.lang.annotation.ElementType;
6 import java.lang.annotation.Retention;
7 import java.lang.annotation.RetentionPolicy;
8 import java.lang.annotation.Target;
9
10 /**
11 * Injects an Element into the field. Only one of the selector types should be specified.
12 *
13 */
14 @Retention(RetentionPolicy.RUNTIME)
15 @Target(ElementType.FIELD)
16 public @interface ElementBy
17 {
18 String id() default "";
19
20 String className() default "";
21
22 String linkText() default "";
23
24 String partialLinkText() default "";
25
26 String cssSelector() default "";
27
28 String name() default "";
29
30 String xpath() default "";
31
32 String tagName() default "";
33
34 /**
35 * Timeout type associated with the injected page element.
36 *
37 * @return timeout of the injected page element
38 * @see TimeoutType
39 */
40 TimeoutType timeoutType() default TimeoutType.DEFAULT;
41
42 /**
43 * <p/>
44 * Type of the PageElement to inject. Used with Iterator<? extends PageElement>
45 * Defaults to the class of the annotated field.
46 *
47 * <p/>
48 * This is not a selector, so you still need to specify a
49 * selector.
50 *
51 * <p/>
52 * This attribute doesn't make sense for injecting PageElements fields,
53 * but it would still work. It makes sense for erased types:
54 * {@code @ElementBy(name="checkbox1", pageElementClass=CheckboxElement.class)
55 * private Iterable<CheckboxElement> checkbox1;
56 * }
57 *
58 * @return target class of the page element
59 * @since 2.1
60 */
61 Class<? extends PageElement> pageElementClass() default PageElement.class;
62
63 /**
64 * The name of the instance variable in the same page object class (or superclass) that is
65 * also annotated with @ElementBy and is a parent context of the page element annotated with
66 * this annotation (i.e. this element on the page is a descendant of the parent element).
67 * That parent page element will be used to find this page element withing its scope.
68 *
69 * @return parent of page element represented by this annotation
70 * @since 2.1
71 */
72 String within() default "";
73 }