diff --git a/lib/core/engine/commands.js b/lib/core/engine/commands.js index 485bba4bd..361be98ef 100644 --- a/lib/core/engine/commands.js +++ b/lib/core/engine/commands.js @@ -227,10 +227,10 @@ export class Commands { * Navigates to a specified URL and handles additional setup for a page visit. * @async * @example await commands.navigate('https://www.example.org'); - * @type {Function} * @param {string} url - The URL to navigate to. * @throws {Error} Throws an error if navigation or setup fails. * @returns {Promise} A promise that resolves when the navigation and setup are + * @type {(url: string) => Promise} */ this.navigate = measure._navigate.bind(measure); @@ -244,7 +244,7 @@ export class Commands { * Add a text that will be an error attached to the current page. * @example await commands.error('My error message'); * @param {string} message - The error message. - * @type {Function} + * @type {(message: string) => void} */ this.error = measure._error.bind(measure); @@ -252,7 +252,7 @@ export class Commands { * Mark this run as an failure. Add a message that explains the failure. * @example await commands.markAsFailure('My failure message'); * @param {string} message - The message attached as a failure - * @type {Function} + * @type {(message: string) => void} */ this.markAsFailure = measure._failure.bind(measure); @@ -485,7 +485,6 @@ export class Commands { * @param {string} text - The text to type into the element. * @returns {Promise} A promise that resolves when the text has been added. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ this.type = async (selector, text) => { return this.addText(selector, text); @@ -502,7 +501,7 @@ export class Commands { * @param {boolean} [options.visible=false] - If true, waits for the element to be visible. * @returns {Promise} A promise that resolves to the WebElement found. * @throws {Error} Throws an error if the element is not found. - * @type {Function} + * @type {(selector: string, options?: { timeout?: number, visible?: boolean }) => Promise} */ this.find = this.element.find.bind(this.element); @@ -518,7 +517,6 @@ export class Commands { * @param {Object} [existsOptions] - Options. * @param {number} [existsOptions.timeout=0] - Maximum time to wait for the element. Default 0 (no wait). * @returns {Promise} True if the element exists. - * @type {Function} */ this.exists = async (selector, existsOptions = {}) => { const { locator } = parseSelector(selector); @@ -552,7 +550,6 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} The visible text content. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ this.getText = async selector => { const element = await findElement(selector); @@ -567,7 +564,6 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} The element's value. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ this.getValue = async selector => { const element = await findElement(selector); @@ -581,7 +577,6 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} True if the element is visible. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ this.isVisible = async selector => { const element = await findElement(selector); @@ -597,7 +592,6 @@ export class Commands { * @param {string} attribute - The attribute name. * @returns {Promise} The attribute value. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ this.getAttribute = async (selector, attribute) => { const element = await findElement(selector); @@ -611,7 +605,6 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} True if the element is enabled. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ this.isEnabled = async selector => { const element = await findElement(selector); @@ -625,7 +618,6 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} True if the element is checked/selected. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ this.isChecked = async selector => { const element = await findElement(selector); @@ -640,7 +632,6 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} A promise that resolves when the element is cleared. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ this.clear = async selector => { const { locator } = parseSelector(selector); @@ -665,7 +656,6 @@ export class Commands { * @param {Object} fields - An object mapping selectors to values. * @returns {Promise} A promise that resolves when all fields are filled. * @throws {Error} Throws an error if any element is not found. - * @type {Function} */ this.fill = async fields => { for (const [selector, text] of Object.entries(fields)) { @@ -682,7 +672,6 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ this.hover = async selector => { return this.mouse.moveTo(selector); @@ -697,7 +686,6 @@ export class Commands { * @example await commands.press('Escape'); * @param {string} key - The key name to press (e.g. 'Enter', 'Tab', 'Escape'). * @returns {Promise} - * @type {Function} */ this.press = async key => { const keyValue = webdriver.Key[key.toUpperCase()] || key; @@ -711,7 +699,6 @@ export class Commands { * @async * @example const title = await commands.getTitle(); * @returns {Promise} The page title. - * @type {Function} */ this.getTitle = async () => { return browser.getDriver().getTitle(); @@ -722,7 +709,6 @@ export class Commands { * @async * @example const url = await commands.getUrl(); * @returns {Promise} The current URL. - * @type {Function} */ this.getUrl = async () => { return browser.getDriver().getCurrentUrl(); @@ -736,7 +722,6 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ this.check = async selector => { const element = await findElement(selector); @@ -754,7 +739,6 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ this.uncheck = async selector => { const element = await findElement(selector); @@ -772,7 +756,6 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ this.scrollIntoView = async selector => { const element = await findElement(selector); @@ -795,7 +778,6 @@ export class Commands { * @param {number} [urlOptions.timeout=10000] - Maximum time to wait in milliseconds. * @returns {Promise} * @throws {Error} Throws an error if the URL does not match within the timeout. - * @type {Function} */ this.waitForUrl = async (pattern, urlOptions = {}) => { const timeout = urlOptions.timeout ?? 10_000; diff --git a/types/core/engine/commands.d.ts b/types/core/engine/commands.d.ts index b71a7afae..dce774a01 100644 --- a/types/core/engine/commands.d.ts +++ b/types/core/engine/commands.d.ts @@ -89,12 +89,12 @@ export class Commands { * Navigates to a specified URL and handles additional setup for a page visit. * @async * @example await commands.navigate('https://www.example.org'); - * @type {Function} * @param {string} url - The URL to navigate to. * @throws {Error} Throws an error if navigation or setup fails. * @returns {Promise} A promise that resolves when the navigation and setup are + * @type {(url: string) => Promise} */ - navigate: Function; + navigate: (url: string) => Promise; /** * Provides functionality to control browser navigation such as back, forward, and refresh actions. * @type {Navigation} @@ -104,16 +104,16 @@ export class Commands { * Add a text that will be an error attached to the current page. * @example await commands.error('My error message'); * @param {string} message - The error message. - * @type {Function} + * @type {(message: string) => void} */ - error: Function; + error: (message: string) => void; /** * Mark this run as an failure. Add a message that explains the failure. * @example await commands.markAsFailure('My failure message'); * @param {string} message - The message attached as a failure - * @type {Function} + * @type {(message: string) => void} */ - markAsFailure: Function; + markAsFailure: (message: string) => void; /** * Executes JavaScript in the browser context. * @type {JavaScript} @@ -215,9 +215,8 @@ export class Commands { * @param {string} text - The text to type into the element. * @returns {Promise} A promise that resolves when the text has been added. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ - type: Function; + type: (selector: string, text: string) => Promise; element: Element; /** * Finds an element using a CSS selector, with optional waiting and visibility check. @@ -229,9 +228,12 @@ export class Commands { * @param {boolean} [options.visible=false] - If true, waits for the element to be visible. * @returns {Promise} A promise that resolves to the WebElement found. * @throws {Error} Throws an error if the element is not found. - * @type {Function} + * @type {(selector: string, options?: { timeout?: number, visible?: boolean }) => Promise} */ - find: Function; + find: (selector: string, options?: { + timeout?: number; + visible?: boolean; + }) => Promise; /** * Checks if an element matching the selector exists in the DOM. * Unlike find(), this does not throw if the element is not found. @@ -244,9 +246,10 @@ export class Commands { * @param {Object} [existsOptions] - Options. * @param {number} [existsOptions.timeout=0] - Maximum time to wait for the element. Default 0 (no wait). * @returns {Promise} True if the element exists. - * @type {Function} */ - exists: Function; + exists: (selector: string, existsOptions?: { + timeout?: number; + }) => Promise; /** * Gets the visible text of an element matching the selector. * @async @@ -255,9 +258,8 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} The visible text content. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ - getText: Function; + getText: (selector: string) => Promise; /** * Gets the value of a form element matching the selector. * @async @@ -266,9 +268,8 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} The element's value. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ - getValue: Function; + getValue: (selector: string) => Promise; /** * Checks if an element matching the selector is visible/displayed. * @async @@ -276,9 +277,8 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} True if the element is visible. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ - isVisible: Function; + isVisible: (selector: string) => Promise; /** * Gets an attribute value of an element matching the selector. * @async @@ -288,9 +288,8 @@ export class Commands { * @param {string} attribute - The attribute name. * @returns {Promise} The attribute value. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ - getAttribute: Function; + getAttribute: (selector: string, attribute: string) => Promise; /** * Checks if a form element matching the selector is enabled. * @async @@ -298,9 +297,8 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} True if the element is enabled. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ - isEnabled: Function; + isEnabled: (selector: string) => Promise; /** * Checks if a checkbox or radio button is selected/checked. * @async @@ -308,9 +306,8 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} True if the element is checked/selected. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ - isChecked: Function; + isChecked: (selector: string) => Promise; /** * Clears the content of a form element matching the selector. * @async @@ -319,9 +316,8 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} A promise that resolves when the element is cleared. * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ - clear: Function; + clear: (selector: string) => Promise; /** * Fills multiple form fields at once. Each key is a selector, each value is the text to type. * @async @@ -334,9 +330,10 @@ export class Commands { * @param {Object} fields - An object mapping selectors to values. * @returns {Promise} A promise that resolves when all fields are filled. * @throws {Error} Throws an error if any element is not found. - * @type {Function} */ - fill: Function; + fill: (fields: { + [x: string]: string; + }) => Promise; /** * Hovers over an element matching the selector. This is a convenience * alias for commands.mouse.moveTo(selector). @@ -346,9 +343,8 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ - hover: Function; + hover: (selector: string) => Promise; /** * Presses a keyboard key. Use key names like 'Enter', 'Tab', 'Escape', * 'Backspace', 'ArrowUp', 'ArrowDown', etc. @@ -358,25 +354,22 @@ export class Commands { * @example await commands.press('Escape'); * @param {string} key - The key name to press (e.g. 'Enter', 'Tab', 'Escape'). * @returns {Promise} - * @type {Function} */ - press: Function; + press: (key: string) => Promise; /** * Gets the title of the current page. * @async * @example const title = await commands.getTitle(); * @returns {Promise} The page title. - * @type {Function} */ - getTitle: Function; + getTitle: () => Promise; /** * Gets the URL of the current page. * @async * @example const url = await commands.getUrl(); * @returns {Promise} The current URL. - * @type {Function} */ - getUrl: Function; + getUrl: () => Promise; /** * Checks a checkbox or radio button. Does nothing if already checked. * @async @@ -385,9 +378,8 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ - check: Function; + check: (selector: string) => Promise; /** * Unchecks a checkbox. Does nothing if already unchecked. * @async @@ -396,9 +388,8 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ - uncheck: Function; + uncheck: (selector: string) => Promise; /** * Scrolls the page so that the element matching the selector is visible in the viewport. * @async @@ -407,9 +398,8 @@ export class Commands { * @param {string} selector - The CSS selector or prefixed selector. * @returns {Promise} * @throws {Error} Throws an error if the element is not found. - * @type {Function} */ - scrollIntoView: Function; + scrollIntoView: (selector: string) => Promise; /** * Waits until the browser's current URL contains the given string. * Useful after form submissions, login redirects, or SPA navigation. @@ -421,9 +411,10 @@ export class Commands { * @param {number} [urlOptions.timeout=10000] - Maximum time to wait in milliseconds. * @returns {Promise} * @throws {Error} Throws an error if the URL does not match within the timeout. - * @type {Function} */ - waitForUrl: Function; + waitForUrl: (pattern: string, urlOptions?: { + timeout?: number; + }) => Promise; } import { PerfettoTrace } from './command/perfetto.js'; import { SimplePerfProfiler } from './command/simpleperf.js'; diff --git a/types/core/engine/commands.d.ts.map b/types/core/engine/commands.d.ts.map index daede1aed..330bdb7da 100644 --- a/types/core/engine/commands.d.ts.map +++ b/types/core/engine/commands.d.ts.map @@ -1 +1 @@ -{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../lib/core/engine/commands.js"],"names":[],"mappings":"AAqCA;;;GAGG;AACH;IACE;;;;;;;;;;;;;;OAiwBC;IAluBC;;;OAGG;IACH,UAFU,aAAa,CAEmD;IAE1E;;;OAGG;IACH,YAFU,kBAAkB,CAO3B;IAQD,+BAMC;IAOD,8BAA0B;IAO1B;;;OAGG;IACH,OAFU,WAAW,CAE+C;IAUpE;;;;;;;;;;;OAWG;IACH,kBALW,MAAM,iBAEd;QAA+B,iBAAiB,GAAxC,OAAO;KACf,KAAU,OAAO,CAAC,IAAI,CAAC,CAGiB;IAY3C;;;OAGG;IACH,QAFU,MAAM,CAE0B;IAU1C;;;;;;;;OAQG;IACH,oBAJW,MAAM,QACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC,CAGW;IAkBrC;;;;;;;;;;OAUG;IACH,iBANW,MAAM,gBAEd;QAA6B,OAAO,GAA5B,MAAM;QACgB,OAAO,GAA7B,OAAO;KACf,KAAU,OAAO,CAAC,IAAI,CAAC,CAGe;IAUzC;;;OAGG;IACH,SAFU,OAAO,CAEK;IAEtB;;;;;;;;OAQG;IACH,mBAA+C;IAE/C;;;OAGG;IACH,YAFU,UAAU,CAEwC;IAE5D;;;;;OAKG;IACH,gBAAyC;IAEzC;;;;;OAKG;IACH,wBAAmD;IAEnD;;;OAGG;IACH,IAFU,UAAU,CAEgC;IAEpD;;;OAGG;IACH,QAFU,MAAM,CAMf;IAUD;;;;;;;;;OASG;IACH,gBALW,MAAM,YACN,MAAM,aACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC,CAGqB;IAU/C;;;OAGG;IACH,WAFU,SAAS,CAEoB;IAEvC;;;OAGG;IACH,OAFU,KAAK,CAEsC;IAErD;;;OAGG;IACH,QAFU,MAAM,CAEiB;IAEjC;;;OAGG;IACH,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AAqB;qBACvB,mBAAmB;2BAJb,yBAAyB;+CAUL,qCAAqC;qBAF/D,mBAAmB;+BACT,sBAAsB;sBAF/B,oBAAoB;6BAWnC,0BAA0B;wBA1BT,sBAAsB;wBAGtB,sBAAsB"} \ No newline at end of file +{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../../lib/core/engine/commands.js"],"names":[],"mappings":"AAqCA;;;GAGG;AACH;IACE;;;;;;;;;;;;;;OA+uBC;IAhtBC;;;OAGG;IACH,UAFU,aAAa,CAEmD;IAE1E;;;OAGG;IACH,YAFU,kBAAkB,CAO3B;IAQD,+BAMC;IAOD,8BAA0B;IAO1B;;;OAGG;IACH,OAFU,WAAW,CAE+C;IAUpE;;;;;;;;;;;OAWG;IACH,kBALW,MAAM,iBAEd;QAA+B,iBAAiB,GAAxC,OAAO;KACf,KAAU,OAAO,CAAC,IAAI,CAAC,CAGiB;IAY3C;;;OAGG;IACH,QAFU,MAAM,CAE0B;IAU1C;;;;;;;;OAQG;IACH,oBAJW,MAAM,QACN,MAAM,KACJ,OAAO,CAAC,IAAI,CAAC,CAGW;IAkBrC;;;;;;;;;;OAUG;IACH,iBANW,MAAM,gBAEd;QAA6B,OAAO,GAA5B,MAAM;QACgB,OAAO,GAA7B,OAAO;KACf,KAAU,OAAO,CAAC,IAAI,CAAC,CAGe;IAUzC;;;OAGG;IACH,SAFU,OAAO,CAEK;IAEtB;;;;;;;;OAQG;IACH,UAFU,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAEO;IAE/C;;;OAGG;IACH,YAFU,UAAU,CAEwC;IAE5D;;;;;OAKG;IACH,OAFU,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAEM;IAEzC;;;;;OAKG;IACH,eAFU,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAEgB;IAEnD;;;OAGG;IACH,IAFU,UAAU,CAEgC;IAEpD;;;OAGG;IACH,QAFU,MAAM,CAMf;IAUD;;;;;;;;;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mBAAmB;2BAJb,yBAAyB;+CAUL,qCAAqC;qBAF/D,mBAAmB;+BACT,sBAAsB;sBAF/B,oBAAoB;6BAWnC,0BAA0B;wBA1BT,sBAAsB;wBAGtB,sBAAsB"} \ No newline at end of file diff --git a/types/scripting.d.ts b/types/scripting.d.ts index df3cab801..f8e14157a 100644 --- a/types/scripting.d.ts +++ b/types/scripting.d.ts @@ -1,2 +1,21 @@ -export { Context as BrowsertimeContext } from './core/engine/context'; -export { Commands as BrowsertimeCommands } from './core/engine/commands'; \ No newline at end of file +export { Context as BrowsertimeContext } from './core/engine/context'; +export { Commands as BrowsertimeCommands } from './core/engine/commands'; + +import { Context as BrowsertimeContext } from './core/engine/context'; +import { Commands as BrowsertimeCommands } from './core/engine/commands'; + +/** + * Signature of a Browsertime user script. Annotate the default export of + * your script with this type to get full IntelliSense on `context` and + * `commands`. + * + * @example + * /** @type {import('browsertime').BrowsertimeScript} *\/ + * export default async function (context, commands) { + * await commands.measure.start('https://example.org'); + * } + */ +export type BrowsertimeScript = ( + context: BrowsertimeContext, + commands: BrowsertimeCommands +) => Promise;