/// declare module 'testcafe' { global { interface KeyModifiers { ctrl?: boolean; alt?: boolean; shift?: boolean; meta?: boolean; } interface CropOptions { /** * The top edge of the cropping rectangle. The coordinate is calculated from the element's top edge. * If a negative number is passed, the coordinate is calculated from the element's bottom edge. */ left?: number; /** * The left edge of the cropping rectangle. The coordinate is calculated from the element's left edge. * If a negative number is passed, the coordinate is calculated from the element's right edge. */ right?: number; /** * The bottom edge of the cropping rectangle. The coordinate is calculated from the element's top edge. * If a negative number is passed, the coordinate is calculated from the element's bottom edge. */ top?: number; /** * The right edge of the cropping rectangle. The coordinate is calculated from the element's left edge. * If a negative number is passed, the coordinate is calculated from the element's right edge. */ bottom?: number; } interface ActionOptions { /** * The speed of action emulation. Defines how fast TestCafe performs the action when running tests. * A value between 1 (the maximum speed) and 0.01 (the minimum speed). If test speed is also specified in the CLI or * programmatically, the action speed setting overrides test speed. Default is 1. */ speed?: number; } interface TakeScreenshotOptions { /** * Specifies the path where the screenshots are saved. */ path?: string; /** * Specifies that TestCafe should take full-page screenshots. */ fullPage?: boolean; } interface TakeElementScreenshotOptions extends ActionOptions { /** * Allows to crop the target element on the screenshot. */ crop?: CropOptions; /** * Controls if element's margins should be included in the screenshot. * Set this property to `true` to include target element's margins in the screenshot. * When it is enabled, the `scrollTargetX`, `scrollTargetY` and `crop` rectangle coordinates are calculated from * the corners where top and left (or bottom and right) margins intersect */ includeMargins?: boolean; /** * Controls if element's borders should be included in the screenshot. * Set this property to `true` to include target element's borders in the screenshot. * When it is enabled, the `scrollTargetX`, `scrollTargetY` and `crop` rectangle coordinates are calculated from * the corners where top and left (or bottom and right) internal edges of the element intersect */ includeBorders?: boolean; /** * Controls if element's paddings should be included in the screenshot. * Set this property to `true` to include target element's paddings in the screenshot. * When it is enabled, the `scrollTargetX`, `scrollTargetY` and `crop` rectangle coordinates are calculated from * the corners where top and left (or bottom and right) edges of the element's content area intersect */ includePaddings?: boolean; /** * Specifies the X coordinate of the scrolling target point. * If the target element is too big to fit into the browser window, the page will be scrolled to put this point * to the center of the viewport. The coordinates of this point are calculated relative to the target element. * If the numbers are positive, the point is positioned relative to the top-left corner of the element. * If the numbers are negative, the point is positioned relative to the bottom-right corner. * If the target element fits into the browser window, these properties have no effect. */ scrollTargetX?: number; /** * Specifies the Y coordinate of the scrolling target point. * If the target element is too big to fit into the browser window, the page will be scrolled to put this point * to the center of the viewport. The coordinates of this point are calculated relative to the target element. * If the numbers are positive, the point is positioned relative to the top-left corner of the element. * If the numbers are negative, the point is positioned relative to the bottom-right corner. * If the target element fits into the browser window, these properties have no effect. */ scrollTargetY?: number; } interface OffsetOptions extends ActionOptions { /** * Mouse pointer X coordinate that define a point where the action is performed or started. * If an offset is a positive integer, coordinates are calculated relative to the top-left corner of the target element. * If an offset is a negative integer, they are calculated relative to the bottom-right corner. * The default is the center of the target element. */ offsetX?: number; /** * Mouse pointer Y coordinate that define a point where the action is performed or started. * If an offset is a positive integer, coordinates are calculated relative to the top-left corner of the target element. * If an offset is a negative integer, they are calculated relative to the bottom-right corner. * The default is the center of the target element. */ offsetY?: number; } interface MouseActionOptions extends OffsetOptions { /** * Indicate which modifier keys are to be pressed during the mouse action. */ modifiers?: KeyModifiers; } interface ClickActionOptions extends MouseActionOptions { /** * The initial caret position if the action is performed on a text input field. A zero-based integer. * The default is the length of the input field content. */ caretPos?: number; } interface TypeActionOptions extends ClickActionOptions { /** * `true` to remove the current text in the target element, and false to leave the text as it is. */ replace?: boolean; /** * `true` to insert the entire block of current text in a single keystroke (similar to a copy & paste function), * and false to insert the current text character by character. */ paste?: boolean; /** * `true` to replace the typed text with a placeholder when sending action logs to a reporter. */ confidential?: boolean; } interface PressActionOptions extends ActionOptions { /** * `true` to replace the pressed keys with a placeholder when sending action logs to a reporter. */ confidential?: boolean; } interface DragToElementOptions extends MouseActionOptions { /** * Mouse pointer X coordinate that defines a point where the dragToElement action is finished. * If an offset is a positive integer, coordinates are calculated relative to the top-left corner of the destination element. * If an offset is a negative integer, they are calculated relative to the bottom-right corner. * By default, the dragToElement action is finished in the center of the destination element. */ destinationOffsetX?: number; /** * Mouse pointer Y coordinate that defines a point where the dragToElement action is finished. * If an offset is a positive integer, coordinates are calculated relative to the top-left corner of the destination element. * If an offset is a negative integer, they are calculated relative to the bottom-right corner. * By default, the dragToElement action is finished in the center of the destination element. */ destinationOffsetY?: number; } interface ResizeToFitDeviceOptions { /** * `true` for portrait screen orientation; `false` for landscape. */ portraitOrientation?: boolean; } interface CookieOptions { /** * The name of the cookie. */ name?: string; /** * The value of the cookie. */ value?: string; /** * The domain attribute of the cookie. */ domain?: string; /** * The path attribute of the cookie. The path must exist on the server to send the Cookie header. */ path?: string; /** * The date and time at which the cookie expires. The browser does not serve the cookie if the client clock is set to a point beyond the cookie expiration time. */ expires?: Date; /** * Cookie expiration time in seconds, relative to the time the cookie is served. */ maxAge?: number | 'Infinity' | '-Infinity'; /** * If the "secure" attribute is "true", the browser only serves the cookie over HTTPS. */ secure?: boolean; /** * Prohibits client-side scripts from accessing the cookie. Helps prevent XSS attacks. */ httpOnly?: boolean; /** * Prohibits the browser from serving the cookie in response to cross-site requests. Helps prevent XSRF attacks. */ sameSite?: string; } interface AssertionOptions { /** * The amount of time, in milliseconds, allowed for an assertion to pass before the test fails if a * selector property or a client function was used in assertion. */ timeout?: number; /** * By default, a Promise is not allowed to be passed to an assertion unless it is a selector property * or the result of a client function. Setting this property to `true` overrides that default. */ allowUnawaitedPromise?: boolean; } interface Assertion { /** * Asserts that `actual` is deeply equal to `expected`. * * @param expected - An expected value. * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ eql(expected: E, message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that actual is deeply equal to expected. * * @param expected - An expected value. * @param options - Assertion options. */ eql(expected: E, options?: AssertionOptions): TestControllerPromise; /** * Assert that `actual` is not deeply equal to `unexpected`. * * @param unexpected - An unexpected value. * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ notEql(unexpected: E, message?: string, options?: AssertionOptions): TestControllerPromise; /** * Assert that `actual` is not deeply equal to `unexpected`. * * @param unexpected - An unexpected value. * @param options - Assertion options. */ notEql(unexpected: E, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is truthy. * * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ ok(message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is truthy. * * @param options - Assertion options. */ ok(options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is falsy. * * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ notOk(message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is falsy. * * @param options - Assertion options. */ notOk(options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` contains `expected`. * * @param expected - An expected value. * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ contains(expected: EnsureString | ElementOf | Extend, message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` contains `expected`. * * @param expected - An expected value. * @param options - Assertion options. */ contains(expected: EnsureString | ElementOf | Extend, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` not contains `unexpected`. * * @param unexpected - An unexpected value. * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ notContains(unexpected: EnsureString | ElementOf | Extend, message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` not contains `unexpected`. * * @param unexpected - An unexpected value. * @param options - Assertion options. */ notContains(unexpected: EnsureString | ElementOf | Extend, options?: AssertionOptions): TestControllerPromise; /** * Asserts that type of `actual` is `typeName`. * * @param typeName - The expected type of an `actual` value. * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ typeOf(typeName: 'function' | 'object' | 'number' | 'string' | 'boolean' | 'undefined' | 'null' | 'regexp', message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that type of `actual` is `typeName`. * * @param typeName - The expected type of an `actual` value. * @param options - Assertion options. */ typeOf(typeName: 'function' | 'object' | 'number' | 'string' | 'boolean' | 'undefined' | 'null' | 'regexp', options?: AssertionOptions): TestControllerPromise; /** * Asserts that type of `actual` is not `typeName`. * * @param typeName - An unexpected type of an `actual` value. * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ notTypeOf(typeName: 'function' | 'object' | 'number' | 'string' | 'boolean' | 'undefined' | 'null' | 'regexp', message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that type of `actual` is not `typeName`. * * @param typeName - An unexpected type of an `actual` value. * @param options - Assertion options. */ notTypeOf(typeName: 'function' | 'object' | 'number' | 'string' | 'boolean' | 'undefined' | 'null' | 'regexp', options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is strictly greater than `expected`. * * @param expected - A value that should be less than or equal to `actual`. * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ gt(expected: number, message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is strictly greater than `expected`. * * @param expected - A value that should be less than or equal to `actual`. * @param options - Assertion options. */ gt(expected: number, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is greater than or equal to `expected`. * * @param expected - A value that should be less than `actual`. * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ gte(expected: number, message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is greater than or equal to `expected`. * * @param expected - A value that should be less than `actual`. * @param options - Assertion options. */ gte(expected: number, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is less than `expected`. * * @param expected - A value that should be greater than or equal to `actual`. * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ lt(expected: number, message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is less than `expected`. * * @param expected - A value that should be greater than or equal to `actual`. * @param options - Assertion options. */ lt(expected: number, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is less than or equal to `expected`. * * @param expected - A value that should be greater than `actual`. * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ lte(expected: number, message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is less than or equal to `expected`. * * @param expected - A value that should be greater than `actual`. * @param options - Assertion options. */ lte(expected: number, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is within a range from `start` to `finish`. Bounds are inclusive. * * @param start - A lower bound of range (included). * @param finish - An upper bound of range (included). * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ within(start: number, finish: number, message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is within a range from `start` to `finish`. Bounds are inclusive. * * @param start - A lower bound of range (included). * @param finish - An upper bound of range (included). * @param options - Assertion options. */ within(start: number, finish: number, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is not within a range from `start` to `finish`. Bounds are inclusive. * * @param start - A lower bound of range (included). * @param finish - An upper bound of range (included). * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ notWithin(start: number, finish: number, message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` is not within a range from `start` to `finish`. Bounds are inclusive. * * @param start - A lower bound of range (included). * @param finish - An upper bound of range (included). * @param options - Assertion options. */ notWithin(start: number, finish: number, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` matches the regular expression. * * @param re - A regular expression that is expected to be matched. * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ match(re: RegExp, message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` matches the regular expression. * * @param re - A regular expression that is expected to be matched. * @param options - Assertion options. */ match(re: RegExp, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` does not match the regular expression. * * @param re - A regular expression that is expected to be matched. * @param message - An assertion message that will be displayed in the report if the test fails. * @param options - Assertion options. */ notMatch(re: RegExp, message?: string, options?: AssertionOptions): TestControllerPromise; /** * Asserts that `actual` does not match the regular expression. * * @param re - A regular expression that is expected to be matched. * @param options - Assertion options. */ notMatch(re: RegExp, options?: AssertionOptions): TestControllerPromise; } interface ClientFunctionOptions { /** * Contains functions, variables or objects used by the client function internally. * Properties of the `dependencies` object will be added to the client function's scope as variables. */ dependencies?: {[key: string]: any}; /** * If you need to call a client function from a Node.js callback, assign the current test controller to the `boundTestRun` option. */ boundTestRun?: TestController; } interface ClientFunction { /** * Client function * * @param args - Function arguments. */ (...args: A): Promise; /** * Returns a new client function with a different set of options that includes options from the * original function and new `options` that overwrite the original ones. * * @param options - New options. */ with(options: ClientFunctionOptions): ClientFunction; } interface ClientFunctionFactory { (fn: (...args: A) => R, options?: ClientFunctionOptions): ClientFunction } interface ClientScriptCommon { page?: any; } interface ClientScriptContent extends ClientScriptCommon { content?: string; } interface ClientScriptModule extends ClientScriptCommon { module?: string; } interface ClientScriptPath extends ClientScriptCommon { path?: string; } type ClientScript = ClientScriptContent | ClientScriptModule | ClientScriptPath; interface TextRectangle { /** * Y-coordinate, relative to the viewport origin, of the bottom of the rectangle box. */ bottom: number; /** * X-coordinate, relative to the viewport origin, of the left of the rectangle box. */ left: number; /** * X-coordinate, relative to the viewport origin, of the right of the rectangle box. */ right: number; /** * Y-coordinate, relative to the viewport origin, of the top of the rectangle box. */ top: number; /** * Width of the rectangle box (This is identical to `right` minus `left`). */ width: number; /** * Height of the rectangle box (This is identical to `bottom` minus `top`). */ height: number; } interface NodeSnapshot { /** * The number of child HTML elements. */ childElementCount: number; /** * The number of child nodes. */ childNodeCount: number; /** * `true` if this node has child HTML elements. */ hasChildElements: boolean; /** * `true` if this node has child nodes. */ hasChildNodes: boolean; /** * The type of the node. * See https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType */ nodeType: number; /** * The text content of the node and its descendants. * See https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent */ textContent: string; /** * Attributes of the element. */ attributes?: {[name: string]: string}; /** * The size of the element and its position relative to the viewport. */ boundingClientRect?: TextRectangle; /** * For checkbox and radio input elements, their current state. For other elements, `undefined`. */ checked?: boolean | undefined; /** * The list of element's classes. */ classNames?: string[]; /** * The inner height of the element, including padding but not the horizontal scrollbar height, border, or margin. * See https://developer.mozilla.org/en-US/docs/Web/API/Element/clientHeight */ clientHeight?: number; /** * The width of the left border of the element. * See https://developer.mozilla.org/en-US/docs/Web/API/Element/clientLeft */ clientLeft?: number; /** * The width of the top border of the element. * See https://developer.mozilla.org/en-US/docs/Web/API/Element/clientTop */ clientTop?: number; /** * The inner width of the element, including padding but not the vertical scrollbar width, border, or margin. * See https://developer.mozilla.org/en-US/docs/Web/API/Element/clientWidth */ clientWidth?: number; /** * `true` if the element is focused. */ focused?: boolean; /** * The element's identifier. * See https://developer.mozilla.org/en-US/docs/Web/API/Element/id */ id?: string; /** * The element's text content "as rendered". * See https://html.spec.whatwg.org/multipage/dom.html#the-innertext-idl-attribute */ innerText?: string; /** * The namespace URI of the element. If the element does not have a namespace, this property is set to null. * See https://developer.mozilla.org/en-US/docs/Web/API/Element/namespaceURI */ namespaceURI?: string | null; /** * The height of the element including vertical padding and borders. * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight */ offsetHeight?: number; /** * The number of pixels that the upper left corner of the element is offset by to the left within the `offsetParent` node. * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetLeft */ offsetLeft?: number; /** * The number of pixels that the upper left corner of the element is offset by to the top within the offsetParent node. * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetTop */ offsetTop?: number; /** * The width of the element including vertical padding and borders. * See https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetWidth */ offsetWidth?: number; /** * Indicates that `