UNPKG

7.3 kBTypeScriptView Raw
1import { Alert, By, ByHash, Condition, Locator, WebDriver, WebElement, WebElementCondition } from '../';
2
3/**
4 * Creates a condition that will wait until the input driver is able to switch
5 * to the designated frame. The target frame may be specified as
6 *
7 * 1. a numeric index into
8 * [window.frames](https://developer.mozilla.org/en-US/docs/Web/API/Window.frames)
9 * for the currently selected frame.
10 * 2. a {@link ./WebElement}, which must reference a FRAME or IFRAME
11 * element on the current page.
12 * 3. a locator which may be used to first locate a FRAME or IFRAME on the
13 * current page before attempting to switch to it.
14 *
15 * Upon successful resolution of this condition, the driver will be left
16 * focused on the new frame.
17 *
18 * @param {!(number|./WebElement|By|function(!./WebDriver): !./WebElement)} frame
19 * The frame identifier.
20 * @return {!Condition<boolean>} A new condition.
21 */
22export function ableToSwitchToFrame(
23 frame: number|WebElement|By|((webdriver: WebDriver) => WebElement)|ByHash): Condition<boolean>;
24
25/**
26 * Creates a condition that waits for an alert to be opened. Upon success, the
27 * returned promise will be fulfilled with the handle for the opened alert.
28 *
29 * @return {!Condition<!./Alert>} The new condition.
30 */
31export function alertIsPresent(): Condition<Alert>;
32
33/**
34 * Creates a condition that will wait for the given element to be disabled.
35 *
36 * @param {!WebElement} element The element to test.
37 * @return {!WebElementCondition} The new condition.
38 * @see WebDriver#isEnabled
39 */
40export function elementIsDisabled(element: WebElement): WebElementCondition;
41
42/**
43 * Creates a condition that will wait for the given element to be enabled.
44 *
45 * @param {!WebElement} element The element to test.
46 * @return {!WebElementCondition} The new condition.
47 * @see WebDriver#isEnabled
48 */
49export function elementIsEnabled(element: WebElement): WebElementCondition;
50
51/**
52 * Creates a condition that will wait for the given element to be deselected.
53 *
54 * @param {!WebElement} element The element to test.
55 * @return {!WebElementCondition} The new condition.
56 * @see WebDriver#isSelected
57 */
58export function elementIsNotSelected(element: WebElement): WebElementCondition;
59
60/**
61 * Creates a condition that will wait for the given element to be in the DOM,
62 * yet not visible to the user.
63 *
64 * @param {!WebElement} element The element to test.
65 * @return {!WebElementCondition} The new condition.
66 * @see WebDriver#isDisplayed
67 */
68export function elementIsNotVisible(element: WebElement): WebElementCondition;
69
70/**
71 * Creates a condition that will wait for the given element to be selected.
72 * @param {!WebElement} element The element to test.
73 * @return {!WebElementCondition} The new condition.
74 * @see WebDriver#isSelected
75 */
76export function elementIsSelected(element: WebElement): WebElementCondition;
77
78/**
79 * Creates a condition that will wait for the given element to become visible.
80 *
81 * @param {!WebElement} element The element to test.
82 * @return {!WebElementCondition} The new condition.
83 * @see WebDriver#isDisplayed
84 */
85export function elementIsVisible(element: WebElement): WebElementCondition;
86
87/**
88 * Creates a condition that will loop until an element is
89 * {@link ./WebDriver#findElement found} with the given locator.
90 *
91 * @param {!(By|Function)} locator The locator to use.
92 * @return {!WebElementCondition} The new condition.
93 */
94export function elementLocated(locator: Locator): WebElementCondition;
95
96/**
97 * Creates a condition that will wait for the given element's
98 * {@link WebDriver#getText visible text} to contain the given
99 * substring.
100 *
101 * @param {!WebElement} element The element to test.
102 * @param {string} substr The substring to search for.
103 * @return {!WebElementCondition} The new condition.
104 * @see WebDriver#getText
105 */
106export function elementTextContains(element: WebElement, substr: string): WebElementCondition;
107
108/**
109 * Creates a condition that will wait for the given element's
110 * {@link WebDriver#getText visible text} to match the given
111 * {@code text} exactly.
112 *
113 * @param {!WebElement} element The element to test.
114 * @param {string} text The expected text.
115 * @return {!WebElementCondition} The new condition.
116 * @see WebDriver#getText
117 */
118export function elementTextIs(element: WebElement, text: string): WebElementCondition;
119
120/**
121 * Creates a condition that will wait for the given element's
122 * {@link WebDriver#getText visible text} to match a regular
123 * expression.
124 *
125 * @param {!WebElement} element The element to test.
126 * @param {!RegExp} regex The regular expression to test against.
127 * @return {!WebElementCondition} The new condition.
128 * @see WebDriver#getText
129 */
130export function elementTextMatches(element: WebElement, regex: RegExp): WebElementCondition;
131
132/**
133 * Creates a condition that will loop until at least one element is
134 * {@link WebDriver#findElement found} with the given locator.
135 *
136 * @param {!(Locator|By.Hash|Function)} locator The locator
137 * to use.
138 * @return {!Condition.<!Array.<!WebElement>>} The new
139 * condition.
140 */
141export function elementsLocated(locator: Locator): Condition<WebElement[]>;
142
143/**
144 * Creates a condition that will wait for the given element to become stale.
145 * An element is considered stale once it is removed from the DOM, or a new
146 * page has loaded.
147 *
148 * @param {!WebElement} element The element that should become stale.
149 * @return {!Condition<boolean>} The new condition.
150 */
151export function stalenessOf(element: WebElement): Condition<boolean>;
152
153/**
154 * Creates a condition that will wait for the current page's title to contain
155 * the given substring.
156 *
157 * @param {string} substr The substring that should be present in the page
158 * title.
159 * @return {!Condition.<boolean>} The new condition.
160 */
161export function titleContains(substr: string): Condition<boolean>;
162
163/**
164 * Creates a condition that will wait for the current page's title to match
165 * the given value.
166 *
167 * @param {string} title The expected page title.
168 * @return {!Condition<boolean>} The new condition.
169 */
170export function titleIs(title: string): Condition<boolean>;
171
172/**
173 * Creates a condition that will wait for the current page's title to match
174 * the given regular expression.
175 *
176 * @param {!RegExp} regex The regular expression to test against.
177 * @return {!Condition.<boolean>} The new condition.
178 */
179export function titleMatches(regex: RegExp): Condition<boolean>;
180
181/**
182 * Creates a condition that will wait for the current page's url to contain
183 * the given substring.
184 *
185 * @param {string} substrUrl The substring that should be present in the
186 * current URL.
187 * @return {!Condition<boolean>} The new condition.
188 */
189export function urlContains(substrUrl: string): Condition<boolean>;
190
191/**
192 * Creates a condition that will wait for the current page's url to match the
193 * given value.
194 *
195 * @param {string} url The expected page url.
196 * @return {!Condition<boolean>} The new condition.
197 */
198export function urlIs(url: string): Condition<boolean>;
199
200/**
201 * Creates a condition that will wait for the current page's url to match the
202 * given regular expression.
203 *
204 * @param {!RegExp} regex The regular expression to test against.
205 * @return {!Condition<boolean>} The new condition.
206 */
207export function urlMatches(regex: RegExp): Condition<boolean>;