1 package com.atlassian.pageobjects.elements;
2
3 import com.atlassian.pageobjects.elements.query.TimedCondition;
4 import com.atlassian.pageobjects.elements.query.TimedQuery;
5 import org.openqa.selenium.Dimension;
6 import org.openqa.selenium.Point;
7
8 import javax.annotation.Nonnull;
9 import java.util.Set;
10
11 /**
12 * Represents an HTML element that is expected in the DOM of a page, all queries return TimedQueries.
13 *
14 */
15 public interface TimedElement
16 {
17 /**
18 * Query representing the existence of this element on a page.
19 *
20 * @return TimedQuery that true if element is present on the page, false if element is not visible or timeout
21 * expires.
22 */
23 TimedCondition isPresent();
24
25 /**
26 * Query representing visibility of this element on a page.
27 *
28 * @return TimedQuery that returns true if element is visible on the page, false if element is not visible
29 * or timeout expires.
30 */
31 TimedCondition isVisible();
32
33 /**
34 * Query representing whether this element is enabled on a page.
35 *
36 * @return TimedQuery that returns true if element is enabled on the page, false if element is disabled or
37 * timeout expires.
38 */
39 TimedCondition isEnabled();
40
41 /**
42 * Query representing whether this element is selected on a page.
43 *
44 * @return TimedQuery that returns true if element is selected on the page, false if element is not selected or
45 * timeout expires.
46 */
47 TimedCondition isSelected();
48
49 /**
50 * Query for the "id" attribute of this element. The query will return {@code null} if the element is not present,
51 * or the "id" attribute is not specified
52 *
53 * @return query for the "id" attribute of this element
54 * @see PageElement#getId()
55 * @since 2.3
56 */
57 @Nonnull
58 TimedQuery<String> getId();
59
60 /**
61 * Query for a set of CSS classes associated with this element.
62 *
63 * @return CSS classes of this element, or an empty set
64 * @return TimedQuery for CSS classes of this element - returns a set of CSS classes, or an empty set otherwise,
65 * incl. if the element does not exist
66 * @see PageElement#getCssClasses()
67 * @since 2.3
68 */
69 @Nonnull
70 TimedQuery<Set<String>> getCssClasses();
71
72 /**
73 * Query representing whether this element has the given classname set.
74 * @param className The name of the class to check
75 * @return TimedQuery that returns true if element has given classname set, false if element does not have the
76 * given classname set or timeout expires.
77 */
78 TimedCondition hasClass(String className);
79
80 /**
81 * Query representing the element's given attribute.
82 *
83 * @param name Name of the attribute
84 *
85 * @return TimedQuery that returns the value of the given attribute, null if element does not have given attribute
86 * or timeout expires.
87 */
88 TimedQuery<String> getAttribute(String name);
89
90 /**
91 * Query representing whether this element has the given attribute set
92 * @param name Name of the attribute
93 * @param value expected attribute value
94 * @return TimedQuery that returns true if element has given attribute set, false if element does not have the
95 * given attribute set or timeout expires
96 */
97 TimedCondition hasAttribute(String name, String value);
98
99 /**
100 * Query representing the element's inner text.
101 *
102 * @return TimedQuery that returns the inner text of the element, null if element does not have inner text
103 * or timeout expires.
104 */
105 TimedQuery<String> getText();
106
107 /**
108 * Query representing whether this element's innerText is equal to the provided string.
109 *
110 * @param text The expected innerText string
111 * @return timed condition that returns <code>true</code> if this element has given innerText equal to expected,
112 * <code>false</code> otherwise
113 */
114 TimedCondition hasText(String text);
115
116 /**
117 * Query representing the element's tag name
118 *
119 * @return TimedQuery that returns the tagname of the element
120 */
121 TimedQuery<String> getTagName();
122
123 /**
124 * Query representing the element's 'value' attribute
125 *
126 * @return TimedQuery that returns the value of the 'value' attribute, null if element does not have a 'value'
127 * attribute or timeout expires.
128 */
129 TimedQuery<String> getValue();
130
131 /**
132 * Query representing whether this element's value attribute is equal to the provided string.
133 *
134 * @param value The expected value attribute
135 * @return timed condition that returns <code>true</code> if this element has given value attribute equal to
136 * expected, <code>false</code> otherwise
137 */
138 TimedCondition hasValue(String value);
139
140 /**
141 * Timed query representing the location of the element on the page.
142 *
143 * @return query for location of the element on the page. Returns <code>null</code>, if the element cannot be located
144 * by given timeout
145 */
146 TimedQuery<Point> getLocation();
147
148 /**
149 * Timed query representing the dimension of the element.
150 *
151 * @return query for dimension of the element on the page. Returns <code>null</code>, if the element cannot be located
152 * by given timeout
153 */
154 TimedQuery<Dimension> getSize();
155 }