UNPKG

@sap_oss/wdio-qmate-service

Version:

[![REUSE status](https://api.reuse.software/badge/github.com/SAP/wdio-qmate-service)](https://api.reuse.software/info/github.com/SAP/wdio-qmate-service)[![Node.js CI](https://github.com/SAP/wdio-qmate-service/actions/workflows/node.js.yml/badge.svg)](http

250 lines (249 loc) 9.77 kB
/** * @class browser * @memberof util */ export declare class Browser { private vlf; private specLogPrefix; private ErrorHandler; /** * @function getBaseUrl * @memberOf util.browser * @description Retrieves the baseUrl from the configuration file. * @returns {String} The baseUrl. * @example const baseUrl = util.browser.getBaseUrl(); */ getBaseUrl(): string; /** * @function setBaseUrl * @memberOf util.browser * @description Sets or overwrites the baseUrl in the configuration file. * @param {String} baseUrl: base URL to set * @example await util.browser.setBaseUrl("https://www.sap.com"); */ setBaseUrl(baseUrl: string): void; /** * @function logCurrentUrl * @memberOf util.browser * @description Displays the current URL in the console. * @example await util.browser.logCurrentUrl(); */ logCurrentUrl(): Promise<void>; /** * @function getCurrentUrl * @memberOf util.browser * @description Returns the current URL * @example await util.browser.getCurrentUrl(); */ getCurrentUrl(): Promise<string>; /** * @function resetFocus * @memberOf util.browser * @description Resets the focus in case it set for a specific element. * @example await util.browser.resetFocus(); */ resetFocus(): Promise<void>; /** * @function sleep * @memberOf util.browser * @description Sleeps (pauses execution) for the passed duration. * @param {Number} [duration=1000] - The time to pause (ms). * @example await util.browser.sleep(30000); */ sleep(duration?: number): Promise<void>; /** * @function collectCoverage * @memberOf util.browser * @description Trigger collection of coverage by coverage service. * @example await util.browser.collectCoverage(); */ collectCoverage(): Promise<void>; /** * @function sleepAndCollectCoverage * @memberOf util.browser * @description Trigger collection of coverage by coverage service. * @param {Number} [duration=1000] - The time to pause (ms). * @example await util.browser.sleepAndCollectCoverage(3000); */ sleepAndCollectCoverage(duration?: number): Promise<void>; /** * @function refresh * @memberOf util.browser * @description Refreshes the page. * @example await util.browser.refresh(); */ refresh(): Promise<void>; /** * @function clearBrowser * @memberOf util.browser * @description Clears the local and session cache and deletes all browser cookies. * @param {Boolean} [clearLocal=true] - Specifies if the local cache will be cleared. * @param {Boolean} [clearSession=true] - Specifies if the session cache will be cleared. * @param {Boolean} [clearCookies=true] - Specifies if the cookies will be cleared. * @example await util.browser.clearBrowser(); */ clearBrowser(clearLocal?: boolean, clearSession?: boolean, clearCookies?: boolean): Promise<void>; /** * @function reloadSession * @memberOf util.browser * @description Clears the browser session, and creates a new one. Use in cases where util.browser.clearBrowser doesn't invalidate login session. * @example await util.browser.reloadSession(); */ reloadSession(): Promise<void>; /** * @function getBrowserName * @memberOf util.browser * @description Retrieves the name of the current browser. * @returns {String} The browser name. * @example const browserName = util.browser.getBrowserName(); */ getBrowserName(): string; /** * @function getUI5Version * @memberOf util.browser * @description Gets the UI5 version and creation date for UI5 based applications. * @param {Number} [timeout=30000] - The timeout to wait (ms). * @example await util.browser.getUI5Version(); */ getUI5Version(timeout?: number): Promise<any>; /** * @function logUI5Version * @memberOf util.browser * @description Logs the UI5 version and creation date for UI5 based applications to the console. * @example await util.browser.logUI5Version(); */ logUI5Version(): Promise<void>; /** * @function executeScript * @memberOf util.browser * @description Executes the specified JavaScript command. * @param {String | Function} command - The command to execute. * @returns {Any} The result from the executed function. * @example await util.browser.executeScript(command); */ executeScript(command: string | Function, ...args: Array<any>): Promise<any>; /** * @function waitUntil * @memberOf util.browser * @description Waits until the specified function returns true or the timeout is reached. * @param {Function} condition - The function to wait for. * @param {Object} [options] - Options for the wait. * @param {Number} [options.timeout] - The timeout to wait (ms). * @param {String} [options.timeoutMsg] - The message to display if the timeout is reached. * @param {Number} [options.interval] - The interval to check the function (ms). * @returns {Promise<void>} Resolves when the function returns true or the timeout is reached. * @example await util.browser.waitUntil(async () => await ui5.element.isVisible(selector), { timeout: 5000, timeoutMsg: "Element not visible" }); */ waitUntil(condition: Function, options?: { timeout?: number; timeoutMsg?: string; interval?: number; }): Promise<void>; /** * @function switchToNewWindow * @memberOf util.browser * @description Switches to the window or tab with the given title. * @param {String|RegExp} titleOrUrl - Window title or url of the expected window or tab (can be either a string or part of it as regular expression). * @param {Number} [timeout=10000] - The timeout to wait (ms). * @example await util.browser.switchToNewWindow("SAP - Home"); * @example await util.browser.switchToNewWindow(/Home/); * @example await util.browser.switchToNewWindow("www.sap.com"); */ switchToNewWindow(titleOrUrl: string | RegExp, timeout?: number): Promise<void>; /** * @function switchToWindow * @memberOf util.browser * @description Switches to the passed window. * @param {Object} handle - The window handle. * @example await util.browser.switchToWindow(originalWindowHandle); */ switchToWindow(handle: object): Promise<void>; /** * @function getCurrentWindow * @memberOf util.browser * @description Returns the current window handle. * @returns {Object} The window handle. * @example const originalWindowHandle = await util.browser.getCurrentWindow(); */ getCurrentWindow(): Promise<any>; /** * @function switchToIframe * @memberOf util.browser * @description Switches to the passed iframe. * @param {String} selector - The CSS selector describing the iframe element. * @example await util.browser.switchToIframe("iframe[id='frame01']"); */ switchToIframe(selector: string): Promise<void>; /** * @function switchToDefaultContent * @memberOf util.browser * @description Switches to the default content of the HTML page. * @example await util.browser.switchToDefaultContent(); */ switchToDefaultContent(): Promise<void>; /** * @function back * @memberOf util.browser * @description Go one step back in browser history. * @example await util.browser.back(); */ back(): Promise<any>; /** * @function forward * @memberOf util.browser * @description Go one step ahead in browser history. * @example await util.browser.forward(); */ forward(): Promise<any>; /** * @function log * @memberOf util.browser * @description add log message to browser logs, can be viewed in the html report * @param {String} message string - The message to be logged. * @example await util.browser.log("Created PO 123456"); */ log(message?: string): Promise<void>; /** * @function warn * @memberOf util.browser * @description add warning message to browser logs, can be viewed in the html report * @param {String} message string - The warning message to be logged. * @example await util.browser.warn("This is a warning message"); */ warn(message?: string): Promise<void>; /** * @function error * @memberOf util.browser * @description add error message to browser logs, can be viewed in the html report * @param {String} message string - The error message to be logged. * @example await util.browser.error("This is an error message"); */ error(message: string): Promise<void>; private _verifyTitleOrUrl; /** * @function isMobile * @memberOf util.browser * @description Indicates a mobile session * @returns {boolean} Return true if its a mobile session driver. * @example await util.browser.isMobile(); */ isMobile(): Promise<boolean>; /** * @function isAndroid * @memberOf util.browser * @description Indicates a mobile session * @returns {boolean} Return true if its a Android session driver. * @example await util.browser.isAndroid(); */ isAndroid(): Promise<boolean>; /** * @function isIos * @memberOf util.browser * @description Indicates an iOS session * @returns {boolean} Return true if its a iOS session driver. * @example await util.browser.isIos(); */ isIos(): Promise<boolean>; } declare const _default: Browser; export default _default;