1 | declare module 'testcafe' {
|
2 | global {
|
3 |
|
4 | interface KeyModifiers {
|
5 | ctrl?: boolean;
|
6 | alt?: boolean;
|
7 | shift?: boolean;
|
8 | meta?: boolean;
|
9 | }
|
10 |
|
11 | interface CropOptions {
|
12 | /**
|
13 | * The top edge of the cropping rectangle. The coordinate is calculated from the element's top edge.
|
14 | * If a negative number is passed, the coordinate is calculated from the element's bottom edge.
|
15 | */
|
16 | left?: number;
|
17 | /**
|
18 | * The left edge of the cropping rectangle. The coordinate is calculated from the element's left edge.
|
19 | * If a negative number is passed, the coordinate is calculated from the element's right edge.
|
20 | */
|
21 | right?: number;
|
22 | /**
|
23 | * The bottom edge of the cropping rectangle. The coordinate is calculated from the element's top edge.
|
24 | * If a negative number is passed, the coordinate is calculated from the element's bottom edge.
|
25 | */
|
26 | top?: number;
|
27 | /**
|
28 | * The right edge of the cropping rectangle. The coordinate is calculated from the element's left edge.
|
29 | * If a negative number is passed, the coordinate is calculated from the element's right edge.
|
30 | */
|
31 | bottom?: number;
|
32 | }
|
33 |
|
34 | interface ActionOptions {
|
35 | /**
|
36 | * The speed of action emulation. Defines how fast TestCafe performs the action when running tests.
|
37 | * A value between 1 (the maximum speed) and 0.01 (the minimum speed). If test speed is also specified in the CLI or
|
38 | * programmatically, the action speed setting overrides test speed. Default is 1.
|
39 | */
|
40 | speed?: number;
|
41 | }
|
42 |
|
43 | interface TakeScreenshotOptions {
|
44 | /**
|
45 | * Specifies the path where the screenshots are saved.
|
46 | */
|
47 | path?: string;
|
48 | /**
|
49 | * Specifies that TestCafe should take full-page screenshots.
|
50 | */
|
51 | fullPage?: boolean;
|
52 | }
|
53 |
|
54 | interface TakeElementScreenshotOptions extends ActionOptions {
|
55 | /**
|
56 | * Allows to crop the target element on the screenshot.
|
57 | */
|
58 | crop?: CropOptions;
|
59 | /**
|
60 | * Controls if element's margins should be included in the screenshot.
|
61 | * Set this property to `true` to include target element's margins in the screenshot.
|
62 | * When it is enabled, the `scrollTargetX`, `scrollTargetY` and `crop` rectangle coordinates are calculated from
|
63 | * the corners where top and left (or bottom and right) margins intersect
|
64 | */
|
65 | includeMargins?: boolean;
|
66 | /**
|
67 | * Controls if element's borders should be included in the screenshot.
|
68 | * Set this property to `true` to include target element's borders in the screenshot.
|
69 | * When it is enabled, the `scrollTargetX`, `scrollTargetY` and `crop` rectangle coordinates are calculated from
|
70 | * the corners where top and left (or bottom and right) internal edges of the element intersect
|
71 | */
|
72 | includeBorders?: boolean;
|
73 | /**
|
74 | * Controls if element's paddings should be included in the screenshot.
|
75 | * Set this property to `true` to include target element's paddings in the screenshot.
|
76 | * When it is enabled, the `scrollTargetX`, `scrollTargetY` and `crop` rectangle coordinates are calculated from
|
77 | * the corners where top and left (or bottom and right) edges of the element's content area intersect
|
78 | */
|
79 | includePaddings?: boolean;
|
80 | /**
|
81 | * Specifies the X coordinate of the scrolling target point.
|
82 | * If the target element is too big to fit into the browser window, the page will be scrolled to put this point
|
83 | * to the center of the viewport. The coordinates of this point are calculated relative to the target element.
|
84 | * If the numbers are positive, the point is positioned relative to the top-left corner of the element.
|
85 | * If the numbers are negative, the point is positioned relative to the bottom-right corner.
|
86 | * If the target element fits into the browser window, these properties have no effect.
|
87 | */
|
88 | scrollTargetX?: number;
|
89 | /**
|
90 | * Specifies the Y coordinate of the scrolling target point.
|
91 | * If the target element is too big to fit into the browser window, the page will be scrolled to put this point
|
92 | * to the center of the viewport. The coordinates of this point are calculated relative to the target element.
|
93 | * If the numbers are positive, the point is positioned relative to the top-left corner of the element.
|
94 | * If the numbers are negative, the point is positioned relative to the bottom-right corner.
|
95 | * If the target element fits into the browser window, these properties have no effect.
|
96 | */
|
97 | scrollTargetY?: number;
|
98 | }
|
99 |
|
100 | interface MouseActionOptions extends ActionOptions {
|
101 | /**
|
102 | * Mouse pointer X coordinate that define a point where the action is performed or started.
|
103 | * If an offset is a positive integer, coordinates are calculated relative to the top-left corner of the target element.
|
104 | * If an offset is a negative integer, they are calculated relative to the bottom-right corner.
|
105 | * The default is the center of the target element.
|
106 | */
|
107 | offsetX?: number;
|
108 | /**
|
109 | * Mouse pointer Y coordinate that define a point where the action is performed or started.
|
110 | * If an offset is a positive integer, coordinates are calculated relative to the top-left corner of the target element.
|
111 | * If an offset is a negative integer, they are calculated relative to the bottom-right corner.
|
112 | * The default is the center of the target element.
|
113 | */
|
114 | offsetY?: number;
|
115 | /**
|
116 | * Indicate which modifier keys are to be pressed during the mouse action.
|
117 | */
|
118 | modifiers?: KeyModifiers;
|
119 | }
|
120 |
|
121 | interface ClickActionOptions extends MouseActionOptions {
|
122 | /**
|
123 | * The initial caret position if the action is performed on a text input field. A zero-based integer.
|
124 | * The default is the length of the input field content.
|
125 | */
|
126 | caretPos?: number;
|
127 | }
|
128 |
|
129 | interface TypeActionOptions extends ClickActionOptions {
|
130 | /**
|
131 | * `true` to remove the current text in the target element, and false to leave the text as it is.
|
132 | */
|
133 | replace?: boolean;
|
134 | /**
|
135 | * `true` to insert the entire block of current text in a single keystroke (similar to a copy & paste function),
|
136 | * and false to insert the current text character by character.
|
137 | */
|
138 | paste?: boolean;
|
139 | }
|
140 |
|
141 | interface DragToElementOptions extends MouseActionOptions {
|
142 | /**
|
143 | * Mouse pointer X coordinate that defines a point where the dragToElement action is finished.
|
144 | * If an offset is a positive integer, coordinates are calculated relative to the top-left corner of the destination element.
|
145 | * If an offset is a negative integer, they are calculated relative to the bottom-right corner.
|
146 | * By default, the dragToElement action is finished in the center of the destination element.
|
147 | */
|
148 | destinationOffsetX?: number;
|
149 | /**
|
150 | * Mouse pointer Y coordinate that defines a point where the dragToElement action is finished.
|
151 | * If an offset is a positive integer, coordinates are calculated relative to the top-left corner of the destination element.
|
152 | * If an offset is a negative integer, they are calculated relative to the bottom-right corner.
|
153 | * By default, the dragToElement action is finished in the center of the destination element.
|
154 | */
|
155 | destinationOffsetY?: number;
|
156 | }
|
157 |
|
158 | interface ResizeToFitDeviceOptions {
|
159 | /**
|
160 | * `true` for portrait screen orientation; `false` for landscape.
|
161 | */
|
162 | portraitOrientation?: boolean;
|
163 | }
|
164 |
|
165 | interface AssertionOptions {
|
166 | /**
|
167 | * The amount of time, in milliseconds, allowed for an assertion to pass before the test fails if a
|
168 | * selector property or a client function was used in assertion.
|
169 | */
|
170 | timeout?: number;
|
171 | /**
|
172 | * By default, a Promise is not allowed to be passed to an assertion unless it is a selector property
|
173 | * or the result of a client function. Setting this property to `true` overrides that default.
|
174 | */
|
175 | allowUnawaitedPromise?: boolean;
|
176 | }
|
177 |
|
178 | interface Assertion<E = any> {
|
179 | /**
|
180 | * Asserts that `actual` is deeply equal to `expected`.
|
181 | *
|
182 | * @param expected - An expected value.
|
183 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
184 | * @param options - Assertion options.
|
185 | */
|
186 | eql(expected: E, message?: string, options?: AssertionOptions): TestControllerPromise;
|
187 | /**
|
188 | * Asserts that actual is deeply equal to expected.
|
189 | *
|
190 | * @param expected - An expected value.
|
191 | * @param options - Assertion options.
|
192 | */
|
193 | eql(expected: E, options?: AssertionOptions): TestControllerPromise;
|
194 | /**
|
195 | * Assert that `actual` is not deeply equal to `unexpected`.
|
196 | *
|
197 | * @param unexpected - An unexpected value.
|
198 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
199 | * @param options - Assertion options.
|
200 | */
|
201 | notEql(unexpected: E, message?: string, options?: AssertionOptions): TestControllerPromise;
|
202 | /**
|
203 | * Assert that `actual` is not deeply equal to `unexpected`.
|
204 | *
|
205 | * @param unexpected - An unexpected value.
|
206 | * @param options - Assertion options.
|
207 | */
|
208 | notEql(unexpected: E, options?: AssertionOptions): TestControllerPromise;
|
209 | /**
|
210 | * Asserts that `actual` is truthy.
|
211 | *
|
212 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
213 | * @param options - Assertion options.
|
214 | */
|
215 | ok(message?: string, options?: AssertionOptions): TestControllerPromise;
|
216 | /**
|
217 | * Asserts that `actual` is truthy.
|
218 | *
|
219 | * @param options - Assertion options.
|
220 | */
|
221 | ok(options?: AssertionOptions): TestControllerPromise;
|
222 | /**
|
223 | * Asserts that `actual` is falsy.
|
224 | *
|
225 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
226 | * @param options - Assertion options.
|
227 | */
|
228 | notOk(message?: string, options?: AssertionOptions): TestControllerPromise;
|
229 | /**
|
230 | * Asserts that `actual` is falsy.
|
231 | *
|
232 | * @param options - Assertion options.
|
233 | */
|
234 | notOk(options?: AssertionOptions): TestControllerPromise;
|
235 | /**
|
236 | * Asserts that `actual` contains `expected`.
|
237 | *
|
238 | * @param expected - An expected value.
|
239 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
240 | * @param options - Assertion options.
|
241 | */
|
242 | contains<R>(expected: EnsureString<E> | ElementOf<E> | Extend<E, R>, message?: string, options?: AssertionOptions): TestControllerPromise;
|
243 | /**
|
244 | * Asserts that `actual` contains `expected`.
|
245 | *
|
246 | * @param expected - An expected value.
|
247 | * @param options - Assertion options.
|
248 | */
|
249 | contains<R>(expected: EnsureString<E> | ElementOf<E> | Extend<E, R>, options?: AssertionOptions): TestControllerPromise;
|
250 | /**
|
251 | * Asserts that `actual` not contains `unexpected`.
|
252 | *
|
253 | * @param unexpected - An unexpected value.
|
254 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
255 | * @param options - Assertion options.
|
256 | */
|
257 | notContains<R>(unexpected: EnsureString<E> | ElementOf<E> | Extend<E, R>, message?: string, options?: AssertionOptions): TestControllerPromise;
|
258 | /**
|
259 | * Asserts that `actual` not contains `unexpected`.
|
260 | *
|
261 | * @param unexpected - An unexpected value.
|
262 | * @param options - Assertion options.
|
263 | */
|
264 | notContains<R>(unexpected: EnsureString<E> | ElementOf<E> | Extend<E, R>, options?: AssertionOptions): TestControllerPromise;
|
265 | /**
|
266 | * Asserts that type of `actual` is `typeName`.
|
267 | *
|
268 | * @param typeName - The expected type of an `actual` value.
|
269 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
270 | * @param options - Assertion options.
|
271 | */
|
272 | typeOf(typeName: 'function' | 'object' | 'number' | 'string' | 'boolean' | 'undefined' | 'null' | 'regexp', message?: string, options?: AssertionOptions): TestControllerPromise;
|
273 | /**
|
274 | * Asserts that type of `actual` is `typeName`.
|
275 | *
|
276 | * @param typeName - The expected type of an `actual` value.
|
277 | * @param options - Assertion options.
|
278 | */
|
279 | typeOf(typeName: 'function' | 'object' | 'number' | 'string' | 'boolean' | 'undefined' | 'null' | 'regexp', options?: AssertionOptions): TestControllerPromise;
|
280 | /**
|
281 | * Asserts that type of `actual` is not `typeName`.
|
282 | *
|
283 | * @param typeName - An unexpected type of an `actual` value.
|
284 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
285 | * @param options - Assertion options.
|
286 | */
|
287 | notTypeOf(typeName: 'function' | 'object' | 'number' | 'string' | 'boolean' | 'undefined' | 'null' | 'regexp', message?: string, options?: AssertionOptions): TestControllerPromise;
|
288 | /**
|
289 | * Asserts that type of `actual` is not `typeName`.
|
290 | *
|
291 | * @param typeName - An unexpected type of an `actual` value.
|
292 | * @param options - Assertion options.
|
293 | */
|
294 | notTypeOf(typeName: 'function' | 'object' | 'number' | 'string' | 'boolean' | 'undefined' | 'null' | 'regexp', options?: AssertionOptions): TestControllerPromise;
|
295 | /**
|
296 | * Asserts that `actual` is strictly greater than `expected`.
|
297 | *
|
298 | * @param expected - A value that should be less than or equal to `actual`.
|
299 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
300 | * @param options - Assertion options.
|
301 | */
|
302 | gt(expected: number, message?: string, options?: AssertionOptions): TestControllerPromise;
|
303 | /**
|
304 | * Asserts that `actual` is strictly greater than `expected`.
|
305 | *
|
306 | * @param expected - A value that should be less than or equal to `actual`.
|
307 | * @param options - Assertion options.
|
308 | */
|
309 | gt(expected: number, options?: AssertionOptions): TestControllerPromise;
|
310 | /**
|
311 | * Asserts that `actual` is greater than or equal to `expected`.
|
312 | *
|
313 | * @param expected - A value that should be less than `actual`.
|
314 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
315 | * @param options - Assertion options.
|
316 | */
|
317 | gte(expected: number, message?: string, options?: AssertionOptions): TestControllerPromise;
|
318 | /**
|
319 | * Asserts that `actual` is greater than or equal to `expected`.
|
320 | *
|
321 | * @param expected - A value that should be less than `actual`.
|
322 | * @param options - Assertion options.
|
323 | */
|
324 | gte(expected: number, options?: AssertionOptions): TestControllerPromise;
|
325 | /**
|
326 | * Asserts that `actual` is less than `expected`.
|
327 | *
|
328 | * @param expected - A value that should be greater than or equal to `actual`.
|
329 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
330 | * @param options - Assertion options.
|
331 | */
|
332 | lt(expected: number, message?: string, options?: AssertionOptions): TestControllerPromise;
|
333 | /**
|
334 | * Asserts that `actual` is less than `expected`.
|
335 | *
|
336 | * @param expected - A value that should be greater than or equal to `actual`.
|
337 | * @param options - Assertion options.
|
338 | */
|
339 | lt(expected: number, options?: AssertionOptions): TestControllerPromise;
|
340 | /**
|
341 | * Asserts that `actual` is less than or equal to `expected`.
|
342 | *
|
343 | * @param expected - A value that should be greater than `actual`.
|
344 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
345 | * @param options - Assertion options.
|
346 | */
|
347 | lte(expected: number, message?: string, options?: AssertionOptions): TestControllerPromise;
|
348 | /**
|
349 | * Asserts that `actual` is less than or equal to `expected`.
|
350 | *
|
351 | * @param expected - A value that should be greater than `actual`.
|
352 | * @param options - Assertion options.
|
353 | */
|
354 | lte(expected: number, options?: AssertionOptions): TestControllerPromise;
|
355 | /**
|
356 | * Asserts that `actual` is within a range from `start` to `finish`. Bounds are inclusive.
|
357 | *
|
358 | * @param start - A lower bound of range (included).
|
359 | * @param finish - An upper bound of range (included).
|
360 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
361 | * @param options - Assertion options.
|
362 | */
|
363 | within(start: number, finish: number, message?: string, options?: AssertionOptions): TestControllerPromise;
|
364 | /**
|
365 | * Asserts that `actual` is within a range from `start` to `finish`. Bounds are inclusive.
|
366 | *
|
367 | * @param start - A lower bound of range (included).
|
368 | * @param finish - An upper bound of range (included).
|
369 | * @param options - Assertion options.
|
370 | */
|
371 | within(start: number, finish: number, options?: AssertionOptions): TestControllerPromise;
|
372 | /**
|
373 | * Asserts that `actual` is not within a range from `start` to `finish`. Bounds are inclusive.
|
374 | *
|
375 | * @param start - A lower bound of range (included).
|
376 | * @param finish - An upper bound of range (included).
|
377 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
378 | * @param options - Assertion options.
|
379 | */
|
380 | notWithin(start: number, finish: number, message?: string, options?: AssertionOptions): TestControllerPromise;
|
381 | /**
|
382 | * Asserts that `actual` is not within a range from `start` to `finish`. Bounds are inclusive.
|
383 | *
|
384 | * @param start - A lower bound of range (included).
|
385 | * @param finish - An upper bound of range (included).
|
386 | * @param options - Assertion options.
|
387 | */
|
388 | notWithin(start: number, finish: number, options?: AssertionOptions): TestControllerPromise;
|
389 | /**
|
390 | * Asserts that `actual` matches the regular expression.
|
391 | *
|
392 | * @param re - A regular expression that is expected to be matched.
|
393 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
394 | * @param options - Assertion options.
|
395 | */
|
396 | match(re: RegExp, message?: string, options?: AssertionOptions): TestControllerPromise;
|
397 | /**
|
398 | * Asserts that `actual` matches the regular expression.
|
399 | *
|
400 | * @param re - A regular expression that is expected to be matched.
|
401 | * @param options - Assertion options.
|
402 | */
|
403 | match(re: RegExp, options?: AssertionOptions): TestControllerPromise;
|
404 | /**
|
405 | * Asserts that `actual` does not match the regular expression.
|
406 | *
|
407 | * @param re - A regular expression that is expected to be matched.
|
408 | * @param message - An assertion message that will be displayed in the report if the test fails.
|
409 | * @param options - Assertion options.
|
410 | */
|
411 | notMatch(re: RegExp, message?: string, options?: AssertionOptions): TestControllerPromise;
|
412 | /**
|
413 | * Asserts that `actual` does not match the regular expression.
|
414 | *
|
415 | * @param re - A regular expression that is expected to be matched.
|
416 | * @param options - Assertion options.
|
417 | */
|
418 | notMatch(re: RegExp, options?: AssertionOptions): TestControllerPromise;
|
419 | }
|
420 |
|
421 | interface ClientFunctionOptions {
|
422 | /**
|
423 | * Contains functions, variables or objects used by the client function internally.
|
424 | * Properties of the `dependencies` object will be added to the client function's scope as variables.
|
425 | */
|
426 | dependencies?: {[key: string]: any};
|
427 | /**
|
428 | * If you need to call a client function from a Node.js callback, assign the current test controller to the `boundTestRun` option.
|
429 | */
|
430 | boundTestRun?: TestController;
|
431 | }
|
432 |
|
433 | interface ClientFunction<R = any, A extends any[]= any[]> {
|
434 | /**
|
435 | * Client function
|
436 | *
|
437 | * @param args - Function arguments.
|
438 | */
|
439 | (...args: A): Promise<R>;
|
440 | /**
|
441 | * Returns a new client function with a different set of options that includes options from the
|
442 | * original function and new `options` that overwrite the original ones.
|
443 | *
|
444 | * @param options - New options.
|
445 | */
|
446 | with(options: ClientFunctionOptions): ClientFunction<R, A>;
|
447 | }
|
448 |
|
449 | interface ClientFunctionFactory {
|
450 | <R, A extends any[]>(fn: (...args: A) => R, options?: ClientFunctionOptions): ClientFunction<R, A>
|
451 | }
|
452 |
|
453 | interface ClientScriptCommon {
|
454 | page?: any;
|
455 | }
|
456 |
|
457 | interface ClientScriptContent extends ClientScriptCommon {
|
458 | content?: string;
|
459 | }
|
460 |
|
461 | interface ClientScriptModule extends ClientScriptCommon {
|
462 | module?: string;
|
463 | }
|
464 |
|
465 | interface ClientScriptPath extends ClientScriptCommon {
|
466 | path?: string;
|
467 | }
|
468 |
|
469 | type ClientScript = ClientScriptContent | ClientScriptModule | ClientScriptPath;
|
470 |
|
471 | interface TextRectangle {
|
472 | /**
|
473 | * Y-coordinate, relative to the viewport origin, of the bottom of the rectangle box.
|
474 | */
|
475 | bottom: number;
|
476 | /**
|
477 | * X-coordinate, relative to the viewport origin, of the left of the rectangle box.
|
478 | */
|
479 | left: number;
|
480 | /**
|
481 | * X-coordinate, relative to the viewport origin, of the right of the rectangle box.
|
482 | */
|
483 | right: number;
|
484 | /**
|
485 | * Y-coordinate, relative to the viewport origin, of the top of the rectangle box.
|
486 | */
|
487 | top: number;
|
488 | /**
|
489 | * Width of the rectangle box (This is identical to `right` minus `left`).
|
490 | */
|
491 | width: number;
|
492 | /**
|
493 | * Height of the rectangle box (This is identical to `bottom` minus `top`).
|
494 | */
|
495 | height: number;
|
496 | }
|
497 |
|
498 | interface NodeSnapshot {
|
499 | /**
|
500 | * The number of child HTML elements.
|
501 | */
|
502 | childElementCount: number;
|
503 | /**
|
504 | * The number of child nodes.
|
505 | */
|
506 | childNodeCount: number;
|
507 | /**
|
508 | * `true` if this node has child HTML elements.
|
509 | */
|
510 | hasChildElements: boolean;
|
511 | /**
|
512 | * `true` if this node has child nodes.
|
513 | */
|
514 | hasChildNodes: boolean;
|
515 | /**
|
516 | * The type of the node.
|
517 | * See https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
518 | */
|
519 | nodeType: number;
|
520 | /**
|
521 | * The text content of the node and its descendants.
|
522 | * See https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent
|
523 | */
|
524 | textContent: string;
|
525 | /**
|
526 | * Attributes of the element.
|
527 | */
|
528 | attributes?: {[name: string]: string};
|
529 | /**
|
530 | * The size of the element and its position relative to the viewport.
|
531 | */
|
532 | boundingClientRect?: TextRectangle;
|
533 | /**
|
534 | * For checkbox and radio input elements, their current state. For other elements, `undefined`.
|
535 | */
|
536 | checked?: boolean | undefined;
|
537 | /**
|
538 | * The list of element's classes.
|
539 | */
|
540 | classNames?: string[];
|
541 | /**
|
542 | * The inner height of the element, including padding but not the horizontal scrollbar height, border, or margin.
|
543 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/clientHeight
|
544 | */
|
545 | clientHeight?: number;
|
546 | /**
|
547 | * The width of the left border of the element.
|
548 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/clientLeft
|
549 | */
|
550 | clientLeft?: number;
|
551 | /**
|
552 | * The width of the top border of the element.
|
553 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/clientTop
|
554 | */
|
555 | clientTop?: number;
|
556 | /**
|
557 | * The inner width of the element, including padding but not the vertical scrollbar width, border, or margin.
|
558 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/clientWidth
|
559 | */
|
560 | clientWidth?: number;
|
561 | /**
|
562 | * `true` if the element is focused.
|
563 | */
|
564 | focused?: boolean;
|
565 | /**
|
566 | * The element's identifier.
|
567 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/id
|
568 | */
|
569 | id?: string;
|
570 | /**
|
571 | * The element's text content "as rendered".
|
572 | * See https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute
|
573 | */
|
574 | innerText?: string;
|
575 | /**
|
576 | * The namespace URI of the element. If the element does not have a namespace, this property is set to null.
|
577 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/namespaceURI
|
578 | */
|
579 | namespaceURI?: string | null;
|
580 | /**
|
581 | * The height of the element including vertical padding and borders.
|
582 | * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight
|
583 | */
|
584 | offsetHeight?: number;
|
585 | /**
|
586 | * The number of pixels that the upper left corner of the element is offset by to the left within the `offsetParent` node.
|
587 | * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetLeft
|
588 | */
|
589 | offsetLeft?: number;
|
590 | /**
|
591 | * The number of pixels that the upper left corner of the element is offset by to the top within the offsetParent node.
|
592 | * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetTop
|
593 | */
|
594 | offsetTop?: number;
|
595 | /**
|
596 | * The width of the element including vertical padding and borders.
|
597 | * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetWidth
|
598 | */
|
599 | offsetWidth?: number;
|
600 | /**
|
601 | * Indicates that `<option>` element is currently selected. For other elements, `undefined`.
|
602 | */
|
603 | selected?: boolean | undefined;
|
604 | /**
|
605 | * For `<select>` element, the index of the first selected `<option>` element. For other elements, `undefined`.
|
606 | */
|
607 | selectedIndex?: number | undefined;
|
608 | /**
|
609 | * The height of the element's content, including content not visible on the screen due to overflow.
|
610 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight
|
611 | */
|
612 | scrollHeight?: number;
|
613 | /**
|
614 | * The number of pixels that the element's content is scrolled to the left.
|
615 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
|
616 | */
|
617 | scrollLeft?: number;
|
618 | /**
|
619 | * The number of pixels that the element's content is scrolled upward.
|
620 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop
|
621 | */
|
622 | scrollTop?: number;
|
623 | /**
|
624 | * Either the width in pixels of the element's content or the width of the element itself, whichever is greater.
|
625 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth
|
626 | */
|
627 | scrollWidth?: number;
|
628 | /**
|
629 | * The computed values of element's CSS properties.
|
630 | */
|
631 | style?: {[prop: string]: string};
|
632 | /**
|
633 | * The name of the element.
|
634 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName
|
635 | */
|
636 | tagName?: string;
|
637 | /**
|
638 | * For input elements, the current value in the control. For other elements, `undefined`.
|
639 | */
|
640 | value?: string | undefined;
|
641 | /**
|
642 | * `true` if the element is visible.
|
643 | */
|
644 | visible?: boolean;
|
645 | /**
|
646 | * `true` if the element has the specified class name.
|
647 | *
|
648 | * @param className - Name of the class.
|
649 | */
|
650 | hasClass?(className: string): boolean;
|
651 | /**
|
652 | * Returns the computed value of the CSS property.
|
653 | *
|
654 | * @param propertyName - The name of the CSS property.
|
655 | */
|
656 | getStyleProperty?(propertyName: string): string;
|
657 | /**
|
658 | * Returns the value of the attribute.
|
659 | *
|
660 | * @param attributeName - The name of the attribute.
|
661 | */
|
662 | getAttribute?(attributeName: string): string;
|
663 | /**
|
664 | * Returns the value of the property from the `boundingClientRect` object.
|
665 | *
|
666 | * @param propertyName - The name of the property.
|
667 | */
|
668 | getBoundingClientRectProperty?(propertyName: string): number;
|
669 | /**
|
670 | * `true` if the element has the attribute.
|
671 | *
|
672 | * @param attributeName - The name of the attribute.
|
673 | */
|
674 | hasAttribute?(attributeName: string): boolean;
|
675 | }
|
676 |
|
677 | // Request Hook
|
678 | //----------------------------------------------------------------------------------------------------------------------
|
679 |
|
680 | interface RequestHook {
|
681 | /**
|
682 | * The `onRequest` method is called before sending the request.
|
683 | */
|
684 | onRequest(requestEvent: object): Promise<void>;
|
685 |
|
686 | /**
|
687 | * The `onResponse` method is called after sending the request
|
688 | */
|
689 | onResponse(responseEvent: object): Promise<void>;
|
690 | }
|
691 |
|
692 | interface RequestHookConstructor {
|
693 | /**
|
694 | * Creates a request hook
|
695 | * @param requestFilterRules - determines which requests the hook handles
|
696 | * @param responseEventConfigureOpts - defines whether to pass the response headers and body to the onResponse method
|
697 | * @returns {RequestHook}
|
698 | */
|
699 | new (requestFilterRules?: Array<any>, responseEventConfigureOpts?: object): RequestHook;
|
700 | }
|
701 |
|
702 | // Request Logger
|
703 | //----------------------------------------------------------------------------------------------------------------------
|
704 |
|
705 | interface RequestLoggerOptions {
|
706 | /**
|
707 | * Specifies whether the request headers should be logged.
|
708 | */
|
709 | logRequestHeaders?: boolean;
|
710 | /**
|
711 | * Specifies whether the request body should be logged.
|
712 | */
|
713 | logRequestBody?: boolean;
|
714 | /**
|
715 | * Specifies whether the request body should be stored as a String or a Buffer.
|
716 | */
|
717 | stringifyRequestBody?: boolean;
|
718 | /**
|
719 | * Specifies whether the response headers should be logged.
|
720 | */
|
721 | logResponseHeaders?: boolean;
|
722 | /**
|
723 | * Specifies whether the response body should be logged.
|
724 | */
|
725 | logResponseBody?: boolean;
|
726 | /**
|
727 | * Specifies whether the response body should be stored as a string or a Buffer.
|
728 | */
|
729 | stringifyResponseBody?: boolean;
|
730 | }
|
731 |
|
732 | interface LoggedRequest {
|
733 | /**
|
734 | * The user agent that sent the request.
|
735 | */
|
736 | userAgent: string;
|
737 | /**
|
738 | * The request part of the logged request
|
739 | */
|
740 | request: RequestData;
|
741 | /**
|
742 | * The response part of the logged request
|
743 | */
|
744 | response: ResponseData;
|
745 | }
|
746 |
|
747 | interface RequestData {
|
748 | /**
|
749 | * The URL where the request is sent.
|
750 | */
|
751 | url: string;
|
752 | /**
|
753 | * The request's HTTP method.
|
754 | */
|
755 | method: string;
|
756 | /**
|
757 | * Request headers in the property-value form. Logged if the `logRequestHeaders` option is set to `true`.
|
758 | */
|
759 | headers: Record<string, string>;
|
760 | /**
|
761 | * The response body. Logged if the `logResponseBody` option is set to `true`.
|
762 | * A [Buffer](https://nodejs.org/api/buffer.html) or string depending on the `stringifyResponseBody` option.
|
763 | */
|
764 | body: string | any;
|
765 | /**
|
766 | * The timestamp that specifies when the request was intercepted.
|
767 | */
|
768 | timestamp: number;
|
769 | }
|
770 |
|
771 | interface ResponseData {
|
772 | /**
|
773 | * The status code received in the response.
|
774 | */
|
775 | statusCode: number;
|
776 | /**
|
777 | * Response headers in the property-value form. Logged if the `logResponseHeaders` option is set to true.
|
778 | */
|
779 | headers: Record<string, string>;
|
780 | /**
|
781 | * The response body.
|
782 | * Logged if the `logResponseBody` option is set to true.
|
783 | * A Buffer or string depending on the `stringifyResponseBody` option.
|
784 | */
|
785 | body: string | any;
|
786 | /**
|
787 | * The timestamp that specifies when the response was intercepted.
|
788 | */
|
789 | timestamp: number;
|
790 | }
|
791 |
|
792 | interface RequestLogger extends RequestHook {
|
793 | /**
|
794 | * Returns whether the logger contains a request that matches the predicate.
|
795 | * @param predicate - The predicate
|
796 | */
|
797 | contains(predicate: (request: LoggedRequest) => boolean): Promise<boolean>;
|
798 | /**
|
799 | * Returns the number of requests that match the predicate.
|
800 | * @param predicate - The predicate
|
801 | */
|
802 | count(predicate: (request: LoggedRequest) => boolean): Promise<number>;
|
803 | /**
|
804 | * Clears all logged requests.
|
805 | */
|
806 | clear(): void;
|
807 | /**
|
808 | * Returns an array of logged requests.
|
809 | */
|
810 | requests: Array<LoggedRequest>;
|
811 | }
|
812 |
|
813 | interface RequestLoggerFactory {
|
814 | (
|
815 | filter?: string | RegExp | object | ((req: any) => boolean),
|
816 | options?: RequestLoggerOptions
|
817 | ): RequestLogger;
|
818 | }
|
819 |
|
820 | // Request Mock
|
821 | //----------------------------------------------------------------------------------------------------------------------
|
822 |
|
823 | interface RequestMock {
|
824 | /**
|
825 | * Specifies requests to intercept
|
826 | * @param filter - Specifies which requests should be mocked with a response that follows in the `respond` method.
|
827 | */
|
828 | onRequestTo(filter: string | RegExp | object | ((req: RequestOptions) => boolean)): RequestMock;
|
829 | /**
|
830 | * Specifies the mocked response.
|
831 | * @param body - The mocked response body.
|
832 | * @param statusCode - The response status code.
|
833 | * @param headers - Custom headers added to the response in the property-value form.
|
834 | */
|
835 | respond(body?: object | string | ((req: RequestOptions, res: ResponseMock) => any), statusCode?: number, headers?: Record<string, string>): RequestMock;
|
836 | }
|
837 |
|
838 | interface RequestMockFactory {
|
839 | (): RequestMock;
|
840 | }
|
841 |
|
842 | /**
|
843 | * {@link https://devexpress.github.io/testcafe/documentation/reference/test-api/requestmock/respond.html#requestoptions See documentation}.
|
844 | */
|
845 | interface RequestOptions {
|
846 | /** The request headers in the property-value form. */
|
847 | headers: Record<string, string>;
|
848 | /** The request body. */
|
849 | body: Buffer;
|
850 | /** The URL of the resource. */
|
851 | url: string;
|
852 | /** The protocol to use. Default: http:. */
|
853 | protocol: string;
|
854 | /** The alias for the host. */
|
855 | hostname: string;
|
856 | /** The domain name or IP address of the server to issue the request to. Default: localhost. */
|
857 | host: string;
|
858 | /** The port of the remote server. Default: 80. */
|
859 | port: number;
|
860 | /**
|
861 | * The request path. Should include query string if any. E.G. '/index.html?page=12'. An exception
|
862 | * is thrown when the request path contains illegal characters. Currently, only spaces are
|
863 | * rejected but that may change in the future. Default: '/'.
|
864 | */
|
865 | path: string;
|
866 | /** The HTTP request method. Default: 'GET'. */
|
867 | method: string;
|
868 | /**
|
869 | * Credentials that were used for authentication in the current session using NTLM or Basic
|
870 | * authentication. For HTTP Basic authentication, these are `username` and `password`. NTLM
|
871 | * authentication additionally specifies `workstation` and `domain`.
|
872 | * See {@link https://devexpress.github.io/testcafe/documentation/guides/advanced-guides/authentication.html#http-authentication HTTP Authentication}.
|
873 | */
|
874 | credentials: Record<string, string>;
|
875 | /**
|
876 | * If a proxy is used, the property contains information about its `host`, `hostname`, `port`,
|
877 | * `proxyAuth`, `authHeader` and `bypassRules`.
|
878 | */
|
879 | proxy: Record<string, unknown>;
|
880 | /**
|
881 | * Specifies whether the request is an AJAX request (xhr or fetch).
|
882 | */
|
883 | isAjax: Boolean;
|
884 | }
|
885 |
|
886 | interface ResponseMock {
|
887 | headers: Record<string, string>;
|
888 | statusCode: number;
|
889 | setBody(value: string): void;
|
890 | }
|
891 |
|
892 | interface Role {
|
893 |
|
894 | }
|
895 |
|
896 | interface RoleOptions {
|
897 | /**
|
898 | * Use this option to control which page is opened after you switch to the role.
|
899 | *
|
900 | * By default, TestCafe navigates back to the page that was opened previously to switching to the role.
|
901 | * Set the `preserveUrl` option to true to save the URL to which the browser was redirected after logging in.
|
902 | * TestCafe will navigate to the saved URL each time after you switch to this role.
|
903 | *
|
904 | * This option is useful if you store session-related data (like session ID) in the URL.
|
905 | */
|
906 | preserveUrl?: boolean;
|
907 | }
|
908 |
|
909 | interface RoleFactory {
|
910 | (url: String, fn: (t: TestController) => Promise<any>, options?: RoleOptions): Role;
|
911 | /**
|
912 | * Creates an anonymous user role.
|
913 | */
|
914 | anonymous(): Role;
|
915 | }
|
916 |
|
917 | interface SelectorOptions {
|
918 | /**
|
919 | * If you need to call a selector from a Node.js callback, assign the current test
|
920 | * controller to the `boundTestRun` option.
|
921 | */
|
922 | boundTestRun?: TestController;
|
923 | /**
|
924 | * The amount of time, in milliseconds, allowed for an element returned by the
|
925 | * selector to appear in the DOM before the test fails.
|
926 | */
|
927 | timeout?: number;
|
928 | /**
|
929 | * Use this option to pass functions, variables or objects to selectors initialized with a function.
|
930 | * The `dependencies` object's properties are added to the function's scope as variables.
|
931 | */
|
932 | dependencies?: {[key: string]: any};
|
933 | /**
|
934 | * `true` to additionally require the returned element to become visible within `options.timeout`.
|
935 | */
|
936 | visibilityCheck?: boolean;
|
937 | }
|
938 |
|
939 | interface SelectorAPI {
|
940 | /**
|
941 | * The number of child HTML elements.
|
942 | */
|
943 | childElementCount: Promise<number>;
|
944 | /**
|
945 | * The number of child nodes.
|
946 | */
|
947 | childNodeCount: Promise<number>;
|
948 | /**
|
949 | * `true` if this node has child HTML elements.
|
950 | */
|
951 | hasChildElements: Promise<boolean>;
|
952 | /**
|
953 | * `true` if this node has child nodes.
|
954 | */
|
955 | hasChildNodes: Promise<boolean>;
|
956 | /**
|
957 | * The type of the node.
|
958 | * See https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType
|
959 | */
|
960 | nodeType: Promise<number>;
|
961 | /**
|
962 | * The text content of the node and its descendants.
|
963 | * See https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent
|
964 | */
|
965 | textContent: Promise<string>;
|
966 | /**
|
967 | * Attributes of the element.
|
968 | */
|
969 | attributes: Promise<{[name: string]: string}>;
|
970 | /**
|
971 | * The size of the element and its position relative to the viewport.
|
972 | */
|
973 | boundingClientRect: Promise<TextRectangle>;
|
974 | /**
|
975 | * For checkbox and radio input elements, their current state. For other elements, `undefined`.
|
976 | */
|
977 | checked: Promise<boolean | undefined>;
|
978 | /**
|
979 | * The list of element's classes.
|
980 | */
|
981 | classNames: Promise<string[]>;
|
982 | /**
|
983 | * The inner height of the element, including padding but not the horizontal scrollbar height, border, or margin.
|
984 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/clientHeight
|
985 | */
|
986 | clientHeight: Promise<number>;
|
987 | /**
|
988 | * The width of the left border of the element.
|
989 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/clientLeft
|
990 | */
|
991 | clientLeft: Promise<number>;
|
992 | /**
|
993 | * The width of the top border of the element.
|
994 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/clientTop
|
995 | */
|
996 | clientTop: Promise<number>;
|
997 | /**
|
998 | * The inner width of the element, including padding but not the vertical scrollbar width, border, or margin.
|
999 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/clientWidth
|
1000 | */
|
1001 | clientWidth: Promise<number>;
|
1002 | /**
|
1003 | * `true` if the element is focused.
|
1004 | */
|
1005 | focused: Promise<boolean>;
|
1006 | /**
|
1007 | * The element's identifier.
|
1008 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/id
|
1009 | */
|
1010 | id: Promise<string>;
|
1011 | /**
|
1012 | * The element's text content "as rendered".
|
1013 | * See https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute
|
1014 | */
|
1015 | innerText: Promise<string>;
|
1016 | /**
|
1017 | * The namespace URI of the element. If the element does not have a namespace, this property is set to null.
|
1018 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/namespaceURI
|
1019 | */
|
1020 | namespaceURI: Promise<string | null>;
|
1021 | /**
|
1022 | * The height of the element including vertical padding and borders.
|
1023 | * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight
|
1024 | */
|
1025 | offsetHeight: Promise<number>;
|
1026 | /**
|
1027 | * The number of pixels that the upper left corner of the element is offset by to the left within the `offsetParent` node.
|
1028 | * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetLeft
|
1029 | */
|
1030 | offsetLeft: Promise<number>;
|
1031 | /**
|
1032 | * The number of pixels that the upper left corner of the element is offset by to the top within the offsetParent node.
|
1033 | * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetTop
|
1034 | */
|
1035 | offsetTop: Promise<number>;
|
1036 | /**
|
1037 | * The width of the element including vertical padding and borders.
|
1038 | * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetWidth
|
1039 | */
|
1040 | offsetWidth: Promise<number>;
|
1041 | /**
|
1042 | * Indicates that `<option>` element is currently selected. For other elements, `undefined`.
|
1043 | */
|
1044 | selected: Promise<boolean | undefined>;
|
1045 | /**
|
1046 | * For `<select>` element, the index of the first selected `<option>` element. For other elements, `undefined`.
|
1047 | */
|
1048 | selectedIndex: Promise<number | undefined>;
|
1049 | /**
|
1050 | * The height of the element's content, including content not visible on the screen due to overflow.
|
1051 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight
|
1052 | */
|
1053 | scrollHeight: Promise<number>;
|
1054 | /**
|
1055 | * The number of pixels that the element's content is scrolled to the left.
|
1056 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
|
1057 | */
|
1058 | scrollLeft: Promise<number>;
|
1059 | /**
|
1060 | * The number of pixels that the element's content is scrolled upward.
|
1061 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollTop
|
1062 | */
|
1063 | scrollTop: Promise<number>;
|
1064 | /**
|
1065 | * Either the width in pixels of the element's content or the width of the element itself, whichever is greater.
|
1066 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth
|
1067 | */
|
1068 | scrollWidth: Promise<number>;
|
1069 | /**
|
1070 | * The computed values of element's CSS properties.
|
1071 | */
|
1072 | style: Promise<{[prop: string]: string}>;
|
1073 | /**
|
1074 | * The name of the element.
|
1075 | * See https://developer.mozilla.org/en-US/docs/Web/API/Element/tagName
|
1076 | */
|
1077 | tagName: Promise<string>;
|
1078 | /**
|
1079 | * For input elements, the current value in the control. For other elements, `undefined`.
|
1080 | */
|
1081 | value: Promise<string | undefined>;
|
1082 | /**
|
1083 | * `true` if the element is visible.
|
1084 | */
|
1085 | visible: Promise<boolean>;
|
1086 | /**
|
1087 | * `true` if the element has the specified class name.
|
1088 | *
|
1089 | * @param className - The name of the class.
|
1090 | */
|
1091 | hasClass(className: string): Promise<boolean>;
|
1092 | /**
|
1093 | * Returns the computed value of the CSS property.
|
1094 | *
|
1095 | * @param propertyName - The name of the CSS property.
|
1096 | */
|
1097 | getStyleProperty(propertyName: string): Promise<string>;
|
1098 | /**
|
1099 | * Returns the value of the attribute.
|
1100 | *
|
1101 | * @param attributeName - The name of the attribute.
|
1102 | */
|
1103 | getAttribute(attributeName: string): Promise<string>;
|
1104 | /**
|
1105 | * Returns the value of the property from the `boundingClientRect` object.
|
1106 | *
|
1107 | * @param propertyName - The name of the property.
|
1108 | */
|
1109 | getBoundingClientRectProperty(propertyName: string): Promise<number>;
|
1110 | /**
|
1111 | * `true` if the element has the attribute.
|
1112 | *
|
1113 | * @param attributeName - The name of the attribute.
|
1114 | */
|
1115 | hasAttribute(attributeName: string): Promise<boolean>;
|
1116 | /**
|
1117 | * Creates a selector that returns an element's `shadowRoot`.
|
1118 | */
|
1119 | shadowRoot(): Selector;
|
1120 | /**
|
1121 | * Creates a selector that returns an element by its index in the matching set.
|
1122 | *
|
1123 | * @param index - A zero-based index of the element. If negative, then counted from the end of the matching set.
|
1124 | */
|
1125 | nth(index: number): Selector;
|
1126 | /**
|
1127 | * Creates a selector that filters a matching set by the specified text.
|
1128 | *
|
1129 | * @param text - The text in the element.
|
1130 | */
|
1131 | withText(text: string): Selector;
|
1132 | /**
|
1133 | * Creates a selector that filters a matching set using the specified regular expression.
|
1134 | *
|
1135 | * @param re - The regular expression for the text in the element.
|
1136 | */
|
1137 | withText(re: RegExp): Selector;
|
1138 | /**
|
1139 | * Creates a selector that filters a matching set by the specified text. Selects elements whose text content *strictly matches* this text.
|
1140 | *
|
1141 | * @param text - The text in the element.
|
1142 | */
|
1143 | withExactText(text: string): Selector;
|
1144 | /**
|
1145 | * Creates a selector that filters a matching set by the specified attribute and, optionally, attribute value.
|
1146 | *
|
1147 | * @param attrName - The attribute name.
|
1148 | * @param attrValue - The attribute value.You can omit this parameter to select elements that have
|
1149 | * the `attrName` attribute regardless of the value.
|
1150 | */
|
1151 | withAttribute(attrName: string | RegExp, attrValue?: string | RegExp): Selector;
|
1152 | /**
|
1153 | * Creates a selector that filters a matching set by cssSelector.
|
1154 | *
|
1155 | * @param cssSelector - A CSS selector string.
|
1156 | */
|
1157 | filter(cssSelector: string): Selector;
|
1158 | /**
|
1159 | * Creates a selector that filters a matching set by the `filterFn` predicate.
|
1160 | *
|
1161 | * @param filterFn - The predicate.
|
1162 | * @param filterFn `node` - The current DOM node.
|
1163 | * @param filterFn `idx` - Index of the current node among other nodes in the matching set.
|
1164 | * @param dependencies - Predicate dependencies.
|
1165 | */
|
1166 | filter(filterFn: (node: Element, idx: number) => boolean,
|
1167 | dependencies?: {[key: string]: any}): Selector;
|
1168 | /**
|
1169 | * Creates a selector that filters a matching set leaving only visible elements.
|
1170 | */
|
1171 | filterVisible(): Selector;
|
1172 | /**
|
1173 | * Creates a selector that filters a matching set leaving only hidden elements.
|
1174 | */
|
1175 | filterHidden(): Selector;
|
1176 | /**
|
1177 | * Finds all descendants of all nodes in the matching set and filters them by `cssSelector`.
|
1178 | *
|
1179 | * @param cssSelector - A CSS selector string.
|
1180 | */
|
1181 | find(cssSelector: string): Selector;
|
1182 | /**
|
1183 | * Finds all descendants of all nodes in the matching set and filters them using `filterFn` predicate.
|
1184 | *
|
1185 | * @param filterFn - The predicate.
|
1186 | * @param filterFn `node` - The current descendant node.
|
1187 | * @param filterFn `idx` - A zero-based index of `node` among other descendant nodes.
|
1188 | * @param filterFn `originNode` - A node from the left-hand selector's matching set whose descendants are being iterated.
|
1189 | * @param dependencies - Predicate dependencies.
|
1190 | */
|
1191 | find(filterFn: (node: Element, idx: number, originNode: Element) => boolean,
|
1192 | dependencies?: {[key: string]: any}): Selector;
|
1193 | /**
|
1194 | * Finds all parents of all nodes in the matching set (first element in the set will be the closest parent).
|
1195 | */
|
1196 | parent(): Selector;
|
1197 | /**
|
1198 | * Finds all parents of all nodes in the matching set and filters them by `index`.
|
1199 | *
|
1200 | * @param index - A zero-based index of the parent (0 is the closest). If negative, then counted from the end of the matching set.
|
1201 | */
|
1202 | parent(index: number): Selector;
|
1203 | /**
|
1204 | * Finds all parents of all nodes in the matching set and filters them by `cssSelector`.
|
1205 | *
|
1206 | * @param cssSelector - A CSS selector string.
|
1207 | */
|
1208 | parent(cssSelector: string): Selector;
|
1209 | /**
|
1210 | * Finds all parents of all nodes in the matching set and filters them by the `filterFn` predicate.
|
1211 | *
|
1212 | * @param filterFn - The predicate.
|
1213 | * @param filterFn `node` - The current parent node.
|
1214 | * @param filterFn `idx` - A zero-based index of `node` among other parent nodes.
|
1215 | * @param filterFn `originNode` - A node from the left-hand selector's matching set whose parents are being iterated.
|
1216 | * @param dependencies - Predicate dependencies.
|
1217 | */
|
1218 | parent(filterFn: (node: Element, idx: number, originNode: Element) => boolean,
|
1219 | dependencies?: {[key: string]: any}): Selector;
|
1220 | /**
|
1221 | * Finds all child elements (not nodes) of all nodes in the matching set.
|
1222 | */
|
1223 | child(): Selector;
|
1224 | /**
|
1225 | * Finds all child elements (not nodes) of all nodes in the matching set and filters them by `index`.
|
1226 | *
|
1227 | * @param index - A zero-based index of the child. If negative, then counted from the end of the matching set.
|
1228 | */
|
1229 | child(index: number): Selector;
|
1230 | /**
|
1231 | * Finds all child elements (not nodes) of all nodes in the matching set and filters them by `cssSelector`.
|
1232 | *
|
1233 | * @param cssSelector - A CSS selector string.
|
1234 | */
|
1235 | child(cssSelector: string): Selector;
|
1236 | /**
|
1237 | * Finds all child elements (not nodes) of all nodes in the matching set and filters them by the `filterFn` predicate.
|
1238 | *
|
1239 | * @param filterFn - The predicate.
|
1240 | * @param filterFn `node` - The current child node.
|
1241 | * @param filterFn `idx` - A zero-based index of `node` among other child nodes.
|
1242 | * @param filterFn `originNode` - A node from the left-hand selector's matching set children parents are being iterated.
|
1243 | * @param dependencies - Predicate dependencies.
|
1244 | */
|
1245 | child(filterFn: (node: Element, idx: number, originNode: Element) => boolean,
|
1246 | dependencies?: {[key: string]: any}): Selector;
|
1247 | /**
|
1248 | * Finds all sibling elements (not nodes) of all nodes in the matching set.
|
1249 | */
|
1250 | sibling(): Selector;
|
1251 | /**
|
1252 | * Finds all sibling elements (not nodes) of all nodes in the matching set and filters them by `index`.
|
1253 | *
|
1254 | * @param index - a zero-based index of the sibling. If negative, then counted from the end of the matching set.
|
1255 | */
|
1256 | sibling(index: number): Selector;
|
1257 | /**
|
1258 | * nds all sibling elements (not nodes) of all nodes in the matching set and filters them by `cssSelector`.
|
1259 | *
|
1260 | * @param cssSelector - A CSS selector string.
|
1261 | */
|
1262 | sibling(cssSelector: string): Selector;
|
1263 | /**
|
1264 | * Finds all sibling elements (not nodes) of all nodes in the matching set and filters them by the `filterFn` predicate.
|
1265 | *
|
1266 | * @param filterFn - The predicate.
|
1267 | * @param filterFn `node` - The current sibling node.
|
1268 | * @param filterFn `idx` - A zero-based index of `node` among other sibling nodes.
|
1269 | * @param filterFn `originNode` - A node from the left-hand selector's matching set whose siblings are being iterated.
|
1270 | * @param dependencies - Predicate dependencies.
|
1271 | */
|
1272 | sibling(filterFn: (node: Element, idx: number, originNode: Element) => boolean,
|
1273 | dependencies?: {[key: string]: any}): Selector;
|
1274 | /**
|
1275 | * Finds all succeeding sibling elements (not nodes) of all nodes in the matching set.
|
1276 | */
|
1277 | nextSibling(): Selector;
|
1278 | /**
|
1279 | * Finds all succeeding sibling elements (not nodes) of all nodes in the matching set and filters them by `index`.
|
1280 | *
|
1281 | * @param index - A zero-based index of the succeeding sibling. If negative, then counted from the end of the matching set.
|
1282 | */
|
1283 | nextSibling(index: number): Selector;
|
1284 | /**
|
1285 | * Finds all succeeding sibling elements (not nodes) of all nodes in the matching set and filters them by `cssSelector`.
|
1286 | *
|
1287 | * @param cssSelector - A CSS selector string.
|
1288 | */
|
1289 | nextSibling(cssSelector: string): Selector;
|
1290 | /**
|
1291 | * Finds all succeeding sibling elements (not nodes) of all nodes in the matching set and filters them by the `filterFn` predicate.
|
1292 | *
|
1293 | * @param filterFn - The predicate.
|
1294 | * @param filterFn `node` - The current succeeding sibling node.
|
1295 | * @param filterFn `idx` - A zero-based index of `node` among other succeeding sibling nodes.
|
1296 | * @param filterFn `originNode` - A node from the left-hand selector's matching set whose succeeding siblings are being iterated.
|
1297 | * @param dependencies - Predicate dependencies.
|
1298 | */
|
1299 | nextSibling(filterFn: (node: Element, idx: number, originNode: Element) => boolean,
|
1300 | dependencies?: {[key: string]: any}): Selector;
|
1301 | /**
|
1302 | * Finds all preceding sibling elements (not nodes) of all nodes in the matching set.
|
1303 | */
|
1304 | prevSibling(): Selector;
|
1305 | /**
|
1306 | * Finds all preceding sibling elements (not nodes) of all nodes in the matching set and filters them by `index`.
|
1307 | *
|
1308 | * @param index - A zero-based index of the preceding sibling. If negative, then counted from the end of the matching set.
|
1309 | */
|
1310 | prevSibling(index: number): Selector;
|
1311 | /**
|
1312 | * Finds all preceding sibling elements (not nodes) of all nodes in the matching set and filters them by `cssSelector`.
|
1313 | *
|
1314 | * @param cssSelector - A CSS selector string.
|
1315 | */
|
1316 | prevSibling(cssSelector: string): Selector;
|
1317 | /**
|
1318 | * Finds all preceding sibling elements (not nodes) of all nodes in the matching set and filters them by the `filterFn` predicate.
|
1319 | *
|
1320 | * @param filterFn - The predicate.
|
1321 | * @param filterFn `node` - The current preceding sibling node.
|
1322 | * @param filterFn `idx` - A zero-based index of `node` among other preceding sibling nodes.
|
1323 | * @param filterFn `originNode` - A node from the left-hand selector's matching set whose preceding siblings are being iterated.
|
1324 | * @param dependencies - Predicate dependencies.
|
1325 | */
|
1326 | prevSibling(filterFn: (node: Element, idx: number, originNode: Element) => boolean,
|
1327 | dependencies?: {[key: string]: any}): Selector;
|
1328 | /**
|
1329 | * `true if` at least one matching element exists.
|
1330 | */
|
1331 | exists: Promise<boolean>;
|
1332 | /**
|
1333 | * The number of matching elements.
|
1334 | */
|
1335 | count: Promise<number>;
|
1336 | /**
|
1337 | * Adds custom selector properties.
|
1338 | *
|
1339 | * @param props - Property descriptors.
|
1340 | * @param props `prop` - Property name.
|
1341 | * @param props `[prop]` - The function that calculate property values. Executed on the client side in the browser.
|
1342 | * @param props `node` - The matching DOM node for which custom property is calculated.
|
1343 | */
|
1344 | addCustomDOMProperties(props: {[prop: string]: (node: Element) => any}): Selector;
|
1345 | /**
|
1346 | * Adds custom selector methods.
|
1347 | *
|
1348 | * @param methods - Method descriptors.
|
1349 | * @param methods `method` - The method name.
|
1350 | * @param methods `[method]` - The function that contains method code. Executed on the client side in the browser.
|
1351 | * @param methods `node` - The matching DOM node for which custom method is executed.
|
1352 | * @param methods `methodParams` - Custom method parameters.
|
1353 | */
|
1354 | addCustomMethods(methods: {[method: string]: (node: Element, ...methodParams: any[]) => any }, opts?: {returnDOMNodes?: boolean}): Selector;
|
1355 | /**
|
1356 | * Returns a new selector with a different set of options that includes options from the
|
1357 | * original selector and new `options` that overwrite the original ones.
|
1358 | *
|
1359 | * @param options - New options.
|
1360 | */
|
1361 | with(options?: SelectorOptions): Selector;
|
1362 | }
|
1363 |
|
1364 | interface Selector extends SelectorAPI {
|
1365 | /**
|
1366 | * Creates parametrized selector.
|
1367 | *
|
1368 | * @param args - Selector parameters.
|
1369 | */
|
1370 | (...args: any[]): SelectorPromise;
|
1371 | }
|
1372 |
|
1373 | interface SelectorPromise extends SelectorAPI, Promise<NodeSnapshot> {
|
1374 | }
|
1375 |
|
1376 | interface SelectorFactory {
|
1377 | (
|
1378 | init:
|
1379 | | string
|
1380 | | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection)
|
1381 | | Selector
|
1382 | | NodeSnapshot
|
1383 | | SelectorPromise,
|
1384 | options?: SelectorOptions
|
1385 | ): Selector;
|
1386 | }
|
1387 |
|
1388 | interface HTTPAuthCredentials {
|
1389 | /**
|
1390 | * The user name for the account.
|
1391 | */
|
1392 | username: string;
|
1393 | /**
|
1394 | * The password for the account.
|
1395 | */
|
1396 | password: string;
|
1397 | /**
|
1398 | * The domain name.
|
1399 | */
|
1400 | domain?: string;
|
1401 | /**
|
1402 | * The workstation's ID in the local network.
|
1403 | */
|
1404 | workstation?: string;
|
1405 | }
|
1406 |
|
1407 | interface FixtureFn {
|
1408 | /**
|
1409 | * Declares a test fixture.
|
1410 | *
|
1411 | * @param name - The name of the fixture.
|
1412 | * @param tagArgs - tag function arguments required to support the "fixture`${x}`" syntax
|
1413 | */
|
1414 | (name: string | TemplateStringsArray, ...tagArgs: any[]): this;
|
1415 | /**
|
1416 | * Specifies a webpage at which all tests in a fixture start.
|
1417 | *
|
1418 | * @param url - The URL of the webpage where tests start.
|
1419 | * @param tagArgs - tag function arguments required to support the "fixture.page`${x}`" syntax
|
1420 | * To test webpages in local directories, you can use the `file://` scheme or relative paths.
|
1421 | */
|
1422 | page(url: string | TemplateStringsArray, ...tagArgs: any[]): this;
|
1423 | /**
|
1424 | * Specifies HTTP Basic or Windows (NTLM) authentication credentials for all tests in the fixture.
|
1425 | *
|
1426 | * @param credentials - Contains credentials used for authentication.
|
1427 | */
|
1428 | httpAuth(credentials: HTTPAuthCredentials): this;
|
1429 | /**
|
1430 | * Specifies the fixture hook that is executed before the start of the first test in the fixture.
|
1431 | *
|
1432 | * @param fn - An asynchronous hook function that contains initialization or clean-up code.
|
1433 | * @param fn `ctx` - A fixture context object used to share variables between fixture hooks and test code.
|
1434 | */
|
1435 | before(fn: (ctx: {[key: string]: any}) => Promise<any>): this;
|
1436 | /**
|
1437 | * Specifies the fixture hook that is executed after the end of the last test in the fixture.
|
1438 | *
|
1439 | * @param fn - An asynchronous hook function that contains initialization or clean-up code.
|
1440 | * @param fn `ctx` - A fixture context object used to share variables between fixture hooks and test code.
|
1441 | */
|
1442 | after(fn: (ctx: {[key: string]: any}) => Promise<any>): this;
|
1443 | /**
|
1444 | * Specifies the hook that is executed on the start of each test in the fixture.
|
1445 | *
|
1446 | * @param fn - An asynchronous hook function that contains initialization or clean-up code.
|
1447 | * @param fn `t` - The test controller used to access test run API.
|
1448 | */
|
1449 | beforeEach(fn: (t: TestController) => Promise<any>): this;
|
1450 | /**
|
1451 | * Specifies the hook that is executed on the end of each test in the fixture.
|
1452 | *
|
1453 | * @param fn - An asynchronous hook function that contains initialization or clean-up code.
|
1454 | * @param fn `t` - The test controller used to access test run API.
|
1455 | */
|
1456 | afterEach(fn: (t: TestController) => Promise<any>): this;
|
1457 | /**
|
1458 | * Skips execution of all tests in the fixture.
|
1459 | */
|
1460 | skip: this;
|
1461 | /**
|
1462 | * Skips execution of all tests, except whose that are in this fixture.
|
1463 | */
|
1464 | only: this;
|
1465 | /**
|
1466 | * Disables page caching for tests in this fixture.
|
1467 | */
|
1468 | disablePageCaching: this;
|
1469 | /**
|
1470 | * WARNING: This feature is experimental and is not recommended for everyday use. It can be removed in the future TestCafe versions.
|
1471 | *
|
1472 | * Disables page reloading which would happen right before each test in this fixture.
|
1473 | */
|
1474 | disablePageReloads: this;
|
1475 | /**
|
1476 | * Specifies the additional information for all tests in the fixture. This information can be used in reports.
|
1477 | *
|
1478 | * @param key - The name of the metadata entry
|
1479 | * @param value - The value of the metadata entry
|
1480 | */
|
1481 | meta(key: string, value: string): this;
|
1482 | /**
|
1483 | * Specifies the additional information for all tests in the fixture. This information can be used in reports.
|
1484 | *
|
1485 | * @param data - Key-value pairs
|
1486 | */
|
1487 | meta(data: object): this;
|
1488 | /**
|
1489 | * Attaches hooks to all tests in the fixture
|
1490 | *
|
1491 | * @param hooks - The set of the RequestHook subclasses
|
1492 | */
|
1493 | requestHooks(...hooks: object[]): this;
|
1494 | /**
|
1495 | * Injects scripts into pages visited during the fixture execution.
|
1496 | *
|
1497 | * @param scripts - Scripts that should be added to the tested pages.
|
1498 | */
|
1499 | clientScripts (scripts: ClientScript | ClientScript[]): this;
|
1500 | }
|
1501 |
|
1502 | interface TestFn {
|
1503 | /**
|
1504 | * Declares a test.
|
1505 | *
|
1506 | * @param name - The name of the test.
|
1507 | * @param fn - An asynchronous function that contains test code.
|
1508 | * @param fn `t` - The test controller used to access test run API.
|
1509 | */
|
1510 | (name: string, fn: (t: TestController) => Promise<any>): this;
|
1511 | /**
|
1512 | * Specifies a webpage at which test starts.
|
1513 | *
|
1514 | * @param url - The URL of the webpage at which this test starts.
|
1515 | * To test webpages in local directories, you can use the `file://` scheme or relative paths.
|
1516 | */
|
1517 | page(url: string): this;
|
1518 | /**
|
1519 | * Specifies HTTP Basic or Windows (NTLM) authentication credentials for the test.
|
1520 | *
|
1521 | * @param credentials - Contains credentials used for authentication.
|
1522 | */
|
1523 | httpAuth(credentials: HTTPAuthCredentials): this;
|
1524 | /**
|
1525 | * Specifies hook that is executed on the start of the test.
|
1526 | *
|
1527 | * @param fn - An asynchronous hook function that contains initialization or clean-up code.
|
1528 | * @param fn `t` - The test controller used to access test run API.
|
1529 | */
|
1530 | before(fn: (t: TestController) => Promise<any>): this;
|
1531 | /**
|
1532 | * Specifies hook that is executed on the end of the test.
|
1533 | *
|
1534 | * @param fn - An asynchronous hook function that contains initialization or clean-up code.
|
1535 | * @param fn `t` - The test controller used to access test run API.
|
1536 | */
|
1537 | after(fn: (t: TestController) => Promise<any>): this;
|
1538 | /**
|
1539 | * Skips test execution.
|
1540 | */
|
1541 | skip: this;
|
1542 | /**
|
1543 | * Skips execution of all tests, except this one.
|
1544 | */
|
1545 | only: this;
|
1546 | /**
|
1547 | * Disables page caching for this test.
|
1548 | */
|
1549 | disablePageCaching: this;
|
1550 | /**
|
1551 | * WARNING: This feature is experimental and is not recommended for everyday use. It can be removed in the future TestCafe versions.
|
1552 | *
|
1553 | * Disables page reloading which would happen right before this test.
|
1554 | */
|
1555 | disablePageReloads: this;
|
1556 | /**
|
1557 | * Specifies the additional information for the test. This information can be used in reports.
|
1558 | *
|
1559 | * @param key - The name of the metadata entry
|
1560 | * @param value - The value of the metadata entry
|
1561 | */
|
1562 | meta(key: string, value: string): this;
|
1563 | /**
|
1564 | * Specifies the additional information for the test. This information can be used in reports.
|
1565 | *
|
1566 | * @param data - Key-value pairs
|
1567 | */
|
1568 | meta(data: object): this;
|
1569 | /**
|
1570 | * Attaches hooks to the test
|
1571 | *
|
1572 | * @param hooks - The set of the RequestHook subclasses
|
1573 | */
|
1574 | requestHooks(...hooks: object[]): this;
|
1575 | /**
|
1576 | * Injects scripts into pages visited during the test execution.
|
1577 | *
|
1578 | * @param scripts - Scripts that should be added to the tested pages.
|
1579 | */
|
1580 | clientScripts (scripts: ClientScript | ClientScript[]): this;
|
1581 | }
|
1582 |
|
1583 | interface NativeDialogHistoryItem {
|
1584 | /**
|
1585 | * The type of the native dialog.
|
1586 | */
|
1587 | type: 'alert' | 'confirm' | 'beforeunload' | 'prompt';
|
1588 | /**
|
1589 | * Text of the dialog message.
|
1590 | */
|
1591 | text: string;
|
1592 | /**
|
1593 | * The URL of the page that invoked the dialog. Use it to determine if the dialog originated
|
1594 | * from the main window or an `<iframe>`.
|
1595 | */
|
1596 | url: string;
|
1597 | }
|
1598 |
|
1599 | interface BrowserConsoleMessages {
|
1600 | /**
|
1601 | * Messages output to the browser console by the console.log() method.
|
1602 | */
|
1603 | log: string[];
|
1604 | /**
|
1605 | * Warning messages output to the browser console by the console.warn() method.
|
1606 | */
|
1607 | warn: string[];
|
1608 | /**
|
1609 | * Error messages output to the browser console by the console.error() method.
|
1610 | */
|
1611 | error: string[];
|
1612 | /**
|
1613 | * Information messages output to the browser console by the console.info() method.
|
1614 | */
|
1615 | info: string[];
|
1616 | }
|
1617 |
|
1618 | interface Browser {
|
1619 | /**
|
1620 | * The browser alias string specified when tests were launched.
|
1621 | */
|
1622 | alias: string;
|
1623 | /**
|
1624 | * The browser name.
|
1625 | */
|
1626 | name: string;
|
1627 | /**
|
1628 | * The browser version.
|
1629 | */
|
1630 | version: string;
|
1631 | /**
|
1632 | * The platform type.
|
1633 | */
|
1634 | platform: string;
|
1635 | /**
|
1636 | * `true` if the browser runs in headless mode.
|
1637 | */
|
1638 | headless: boolean;
|
1639 | /**
|
1640 | * The name and version of the operating system.
|
1641 | */
|
1642 | os: { name: string; version: string };
|
1643 | /**
|
1644 | * The name and version of the browser engine.
|
1645 | */
|
1646 | engine: { name: string; version: string };
|
1647 | /**
|
1648 | * The user agent string.
|
1649 | */
|
1650 | userAgent: string;
|
1651 | /**
|
1652 | * Formatted string with the browser's and operating system's name and version.
|
1653 | */
|
1654 | prettyUserAgent: string;
|
1655 | }
|
1656 |
|
1657 | type WindowDescriptor = unknown;
|
1658 |
|
1659 | interface WindowFilterData {
|
1660 | /**
|
1661 | * The window title.
|
1662 | */
|
1663 | title: string;
|
1664 |
|
1665 | /**
|
1666 | * The window URL.
|
1667 | */
|
1668 | url: URL;
|
1669 | }
|
1670 |
|
1671 | interface TestController {
|
1672 | /**
|
1673 | * Dictionary that is shared between test hook functions and test code.
|
1674 | */
|
1675 | ctx: {[key: string]: any};
|
1676 | /**
|
1677 | * Dictionary that is shared between `fixture.before` and `fixture.after`, test hook functions and test code.
|
1678 | */
|
1679 | readonly fixtureCtx: {[key: string]: any};
|
1680 | /**
|
1681 | * Returns an object that contains browser information.
|
1682 | */
|
1683 | readonly browser: Browser;
|
1684 | /**
|
1685 | * Clicks a webpage element.
|
1686 | *
|
1687 | * @param selector - Identifies the webpage element being clicked.
|
1688 | * @param options - A set of options that provide additional parameters for the action.
|
1689 | */
|
1690 | click(selector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection),
|
1691 | options?: ClickActionOptions): TestControllerPromise;
|
1692 | /**
|
1693 | * Right-clicks a webpage element.
|
1694 | *
|
1695 | * @param selector - Identifies the webpage element being right-clicked.
|
1696 | * @param options - A set of options that provide additional parameters for the action.
|
1697 | */
|
1698 | rightClick(selector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection),
|
1699 | options?: ClickActionOptions): TestControllerPromise;
|
1700 | /**
|
1701 | * Double-clicks a webpage element.
|
1702 | *
|
1703 | * @param selector - Identifies the webpage element being double-clicked.
|
1704 | * @param options - A set of options that provide additional parameters for the action.
|
1705 | */
|
1706 | doubleClick(selector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection),
|
1707 | options?: ClickActionOptions): TestControllerPromise;
|
1708 | /**
|
1709 | * Hovers the mouse pointer over a webpage element.
|
1710 | *
|
1711 | * @param selector - Identifies the webpage element being hovered over.
|
1712 | * @param options - A set of options that provide additional parameters for the action.
|
1713 | */
|
1714 | hover(selector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection),
|
1715 | options?: MouseActionOptions): TestControllerPromise;
|
1716 | /**
|
1717 | * Drags an element by an offset.
|
1718 | *
|
1719 | * @param selector - Identifies the webpage element being dragged
|
1720 | * @param dragOffsetX - An X-offset of the drop coordinates from the mouse pointer's initial position.
|
1721 | * @param dragOffsetY - An Y-offset of the drop coordinates from the mouse pointer's initial position.
|
1722 | * @param options - A set of options that provide additional parameters for the action.
|
1723 | */
|
1724 | drag(selector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection),
|
1725 | dragOffsetX: number,
|
1726 | dragOffsetY: number,
|
1727 | options?: MouseActionOptions): TestControllerPromise;
|
1728 | /**
|
1729 | * Drags an element onto another one.
|
1730 | *
|
1731 | * @param selector - Identifies the webpage element being dragged.
|
1732 | * @param destinationSelector - Identifies the webpage element that serves as the drop location.
|
1733 | * @param options - A set of options that provide additional parameters for the action.
|
1734 | */
|
1735 | dragToElement(selector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection),
|
1736 | destinationSelector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection),
|
1737 | options?: DragToElementOptions): TestControllerPromise;
|
1738 | /**
|
1739 | * Types the specified text into an input element.
|
1740 | *
|
1741 | * @param selector - Identifies the webpage element that will receive input focus.
|
1742 | * @param text - The text to be typed into the specified webpage element.
|
1743 | * @param options - A set of options that provide additional parameters for the action.
|
1744 | */
|
1745 | typeText(selector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection),
|
1746 | text: string,
|
1747 | options?: TypeActionOptions): TestControllerPromise;
|
1748 | /**
|
1749 | * Selects text in input elements.
|
1750 | *
|
1751 | * @param selector - Identifies the webpage element whose text will be selected.
|
1752 | * @param startPos - The start position of the selection. A zero-based integer.
|
1753 | * @param endPos - The end position of the selection. A zero-based integer.
|
1754 | * @param options - A set of options that provide additional parameters for the action.
|
1755 | */
|
1756 | selectText(selector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection),
|
1757 | startPos?: number,
|
1758 | endPos?: number,
|
1759 | options?: ActionOptions): TestControllerPromise;
|
1760 | /**
|
1761 | * Selects `<textarea>` content.
|
1762 | *
|
1763 | * @param selector
|
1764 | * @param startLine
|
1765 | * @param startPos
|
1766 | * @param endLine
|
1767 | * @param endPos
|
1768 | * @param options
|
1769 | */
|
1770 | selectTextAreaContent(selector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection),
|
1771 | startLine?: number,
|
1772 | startPos?: number,
|
1773 | endLine?: number,
|
1774 | endPos?: number,
|
1775 | options?: ActionOptions): TestControllerPromise;
|
1776 | /**
|
1777 | * Performs selection within editable content
|
1778 | *
|
1779 | * @param startSelector - Identifies a webpage element from which selection starts. The start position of selection is the first character of the element's text.
|
1780 | * @param endSelector - Identifies a webpage element at which selection ends. The end position of selection is the last character of the element's text.
|
1781 | * @param options - A set of options that provide additional parameters for the action.
|
1782 | */
|
1783 | selectEditableContent(startSelector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection),
|
1784 | endSelector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection),
|
1785 | options?: ActionOptions): TestControllerPromise;
|
1786 | /**
|
1787 | * Presses the specified keyboard keys.
|
1788 | *
|
1789 | * @param keys - The sequence of keys and key combinations to be pressed.
|
1790 | * @param options - A set of options that provide additional parameters for the action.
|
1791 | */
|
1792 | pressKey(keys: string, options?: ActionOptions): TestControllerPromise;
|
1793 | /**
|
1794 | * Pauses a test for a specified period of time.
|
1795 | *
|
1796 | * @param timeout - The pause duration, in milliseconds.
|
1797 | */
|
1798 | wait(timeout: number): TestControllerPromise;
|
1799 | /**
|
1800 | * Navigates to the specified URL.
|
1801 | *
|
1802 | * @param url - The URL to navigate to. Absolute or relative to the current page.
|
1803 | * You can use the `file://` scheme or relative paths to navigate to a webpage in a local directory.
|
1804 | */
|
1805 | navigateTo(url: string): TestControllerPromise;
|
1806 | /**
|
1807 | * Populates the specified file upload input with file paths.
|
1808 | *
|
1809 | * @param selector - Identifies the input field to which file paths are written.
|
1810 | * @param filePath - The path to the uploaded file, or several such paths. Relative paths resolve from the folder with the test file.
|
1811 | */
|
1812 | setFilesToUpload(selector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection),
|
1813 | filePath: String | String[]): TestControllerPromise;
|
1814 | /**
|
1815 | * Removes all file paths from the specified file upload input.
|
1816 | *
|
1817 | * @param selector - Identifies the input field that needs to be cleared.
|
1818 | */
|
1819 | clearUpload(selector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection)): TestControllerPromise;
|
1820 | /**
|
1821 | * Takes a screenshot of the tested page.
|
1822 | *
|
1823 | * @param path - relative path to the screenshot file. Resolved from the screenshot directory specified by
|
1824 | * using the `runner.screenshots` API method or the `screenshots-path` command line option.
|
1825 | * If path doesn't have .png extension, it will be added automatically.
|
1826 | */
|
1827 | takeScreenshot(path?: string): TestControllerPromise;
|
1828 | /**
|
1829 | * Takes a screenshot of the tested page.
|
1830 | *
|
1831 | * @param options - TakeScreenshot Options
|
1832 | */
|
1833 | takeScreenshot(options: TakeScreenshotOptions): TestControllerPromise;
|
1834 | /**
|
1835 | * Takes a screenshot of the specified element.
|
1836 | *
|
1837 | * @param selector - Identifies the element for screenshot capturing.
|
1838 | * @param path - relative path to the screenshot file. Resolved from the screenshot directory specified by
|
1839 | * using the `runner.screenshots` API method or the `screenshots-path` command line option.
|
1840 | * If path doesn't have .png extension, it will be added automatically.
|
1841 | */
|
1842 | takeElementScreenshot(selector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection),
|
1843 | path?: string,
|
1844 | options?: TakeElementScreenshotOptions): TestControllerPromise;
|
1845 | /**
|
1846 | * Sets the browser window size.
|
1847 | *
|
1848 | * @param width - The new width, in pixels.
|
1849 | * @param height - The new height, in pixels.
|
1850 | */
|
1851 | resizeWindow(width: number, height: number): TestControllerPromise;
|
1852 |
|
1853 | /**
|
1854 | * Fits the browser window into a particular device.
|
1855 | *
|
1856 | * @param deviceName - The name of the device as listed at https://github.com/DevExpress/device-specs/blob/master/viewport-sizes.json.
|
1857 | * @param options - Provide additional information about the device.
|
1858 | */
|
1859 | resizeWindowToFitDevice(deviceName: string, options?: ResizeToFitDeviceOptions): TestControllerPromise;
|
1860 | /**
|
1861 | * Maximizes the browser window.
|
1862 | */
|
1863 | maximizeWindow(): TestControllerPromise;
|
1864 | /**
|
1865 | * Switches the test's browsing context to the specified `<iframe>`.
|
1866 | *
|
1867 | * @param selector - Identifies an `<iframe>` on the tested page.
|
1868 | */
|
1869 | switchToIframe(selector: string | Selector | NodeSnapshot | SelectorPromise | ((...args: any[]) => Node | Node[] | NodeList | HTMLCollection)): TestControllerPromise;
|
1870 | /**
|
1871 | * Switches the test's browsing context from an `<iframe>` back to the main window.
|
1872 | */
|
1873 | switchToMainWindow(): TestControllerPromise;
|
1874 |
|
1875 | /**
|
1876 | * Opens a new browser window.
|
1877 | *
|
1878 | * @param url - The URL to open. Can be local or remote, absolute or relative.
|
1879 | */
|
1880 | openWindow(url: string): WindowDescriptorPromise;
|
1881 |
|
1882 | /**
|
1883 | * Closes a browser window.
|
1884 | *
|
1885 | * @param windowDescriptor - The target window. If this parameter is omitted, the currently active window is selected.
|
1886 | */
|
1887 | closeWindow(windowDescriptor?: WindowDescriptor): TestControllerPromise;
|
1888 |
|
1889 | /**
|
1890 | * Retrieves a `window` object that corresponds to the currently open window.
|
1891 | */
|
1892 | getCurrentWindow(): WindowDescriptorPromise;
|
1893 |
|
1894 | /**
|
1895 | * Activates the window that corresponds to the `window` object.
|
1896 | *
|
1897 | * @param windowDescriptor - The target window.
|
1898 | */
|
1899 | switchToWindow(windowDescriptor: WindowDescriptor): TestControllerPromise;
|
1900 |
|
1901 | /**
|
1902 | * Activates the first window that matches the criteria passed to the `filterFn` function
|
1903 | *
|
1904 | * @param filterFn - The predicate used to select windows.
|
1905 | */
|
1906 | switchToWindow(filterFn: (data: WindowFilterData) => boolean): TestControllerPromise;
|
1907 |
|
1908 | /**
|
1909 | * Activates the window that launched, or was active during the launch of, the currently active window.
|
1910 | */
|
1911 | switchToParentWindow(): TestControllerPromise;
|
1912 |
|
1913 | /**
|
1914 | * Activates the most recent of the previously active windows.
|
1915 | */
|
1916 | switchToPreviousWindow(): TestControllerPromise;
|
1917 |
|
1918 | /**
|
1919 | * Executes function on client and returns it's result.
|
1920 | *
|
1921 | * @param fn - A function to be executed on the client side.
|
1922 | * @param options - Function options.
|
1923 | */
|
1924 | eval(fn: Function, options?: ClientFunctionOptions): Promise<any>;
|
1925 | /**
|
1926 | * Specifies handler function for the browser native dialogs.
|
1927 | *
|
1928 | * @param fn - A regular or client function that will be triggered whenever a native dialog is invoked. null to
|
1929 | * remove the native dialog handler.
|
1930 | * @param fn `type` - The type of the native dialog.
|
1931 | * @param fn `text` - Text of the dialog message.
|
1932 | * @param fn `url` - The URL of the page that invoked the dialog. Use it to determine if the dialog originated from
|
1933 | * the main window or an `<iframe>`.
|
1934 | * @param options - Handler options.
|
1935 | */
|
1936 | setNativeDialogHandler(fn: ((type: 'alert' | 'confirm' | 'beforeunload' | 'prompt', text: string, url: string) => any) | null,
|
1937 | options?: ClientFunctionOptions): TestControllerPromise;
|
1938 | /**
|
1939 | * Returns a stack of history entries (i.e., an array in which the latest dialog has an index of 0). Each entry
|
1940 | * corresponds to a certain native dialog that appears in the main window or in an `<iframe>`.
|
1941 | */
|
1942 | getNativeDialogHistory(): Promise<NativeDialogHistoryItem[]>;
|
1943 | /**
|
1944 | * Returns an object that contains messages output to the browser console.
|
1945 | */
|
1946 | getBrowserConsoleMessages(): Promise<BrowserConsoleMessages>;
|
1947 | /**
|
1948 | * Starts an assertion chain and specifies assertion actual value.
|
1949 | *
|
1950 | * @param actual - An actual value of the assertion.
|
1951 | */
|
1952 | expect<A>(actual: A | Promise<A>): Assertion<A>;
|
1953 | /**
|
1954 | * Pauses the test and switches to the step-by-step execution mode.
|
1955 | */
|
1956 | debug(): TestControllerPromise;
|
1957 | /**
|
1958 | * Specifies the speed of test execution.
|
1959 | *
|
1960 | * @param speed - Specifies the test speed. Must be a number between 1 (the fastest) and 0.01 (the slowest).
|
1961 | */
|
1962 | setTestSpeed(speed: number): TestControllerPromise;
|
1963 | /**
|
1964 | * Specifies the amount of time within which TestCafe waits for the `window.load` event to fire before starting the test.
|
1965 | *
|
1966 | * @param duration - Specifies the amount of time within which TestCafe waits for the `window.load` event to fire before starting the test.
|
1967 | */
|
1968 | setPageLoadTimeout(duration: number): TestControllerPromise;
|
1969 | /**
|
1970 | * Switches user role.
|
1971 | *
|
1972 | * @param role - The role you need to use further in the test.
|
1973 | */
|
1974 | useRole(role: Role): TestControllerPromise;
|
1975 | /**
|
1976 | * Attaches the hooks during a test run
|
1977 | *
|
1978 | * @param hooks - The set of RequestHook subclasses
|
1979 | */
|
1980 | addRequestHooks(...hooks: object[]): TestControllerPromise;
|
1981 | /**
|
1982 | * Detaches the hooks during a test run
|
1983 | *
|
1984 | * @param hooks - The set of RequestHook subclasses
|
1985 | */
|
1986 | removeRequestHooks(...hooks: object[]): TestControllerPromise;
|
1987 | }
|
1988 |
|
1989 | interface TestControllerPromise<T=any> extends TestController, Promise<T> {
|
1990 | }
|
1991 |
|
1992 | interface WindowDescriptorPromise extends TestControllerPromise<WindowDescriptor> {
|
1993 | }
|
1994 |
|
1995 | type ElementOf<T> = T extends (infer E)[] ? E : never;
|
1996 | type Extend<T, E> = T extends E ? E : never;
|
1997 | type EnsureString<T> = T extends string ? string : never;
|
1998 |
|
1999 | /**
|
2000 | * Creates a selector.
|
2001 | *
|
2002 | * @param init - Selector initializer.
|
2003 | * @param options - Selector options.
|
2004 | */
|
2005 | export const Selector: SelectorFactory;
|
2006 |
|
2007 | /**
|
2008 | * Creates a client function.
|
2009 | *
|
2010 | * @param fn - Function code.
|
2011 | * @param options - Function options.
|
2012 | */
|
2013 | export const ClientFunction: ClientFunctionFactory;
|
2014 | }
|
2015 | }
|
2016 |
|
\ | No newline at end of file |