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

301 lines (300 loc) 16.7 kB
import { Element } from "../../../../@types/wdio"; /** * @class element * @memberof nonUi5 */ export declare class ElementModule { private vlf; private ErrorHandler; /** * @function waitForAll * @memberOf nonUi5.element * @description Waits until all elements with the given selector are rendered. Will fail if no element is found. * @param {Object} selector - The CSS selector describing the element. * @param {Number} [timeout=30000] - The timeout to wait (ms). * @example await nonUi5.element.waitForAll(".inputField"); */ waitForAll(selector: any, timeout?: number, includeHidden?: boolean): Promise<void>; /** * @function waitToBePresent * @memberOf nonUi5.element * @description Waits until the element with the given selector is present. * @param {Object} selector - The CSS selector describing the element. * @param {Number} [timeout=30000] - The timeout to wait (ms). * @example await nonUi5.element.waitToBePresent(".input01"); * @example await nonUi5.element.waitToBePresent("#button12"); * @example await nonUi5.element.waitToBePresent("p:first-child"); */ waitToBePresent(selector: any, timeout?: number): Promise<void>; /** * @function waitToBeVisible * @memberOf nonUi5.element * @description Waits until the element with the given selector is visible. * @param {Object} selector - The CSS selector describing the element. * @param {Number} [timeout=30000] - The timeout to wait (ms). * @example await nonUi5.element.waitToBeVisible(".input01"); * @example await nonUi5.element.waitToBeVisible("#button12"); * @example await nonUi5.element.waitToBeVisible("p:first-child"); */ waitToBeVisible(selector: any, timeout?: number): Promise<void>; /** * @function waitToBeClickable * @memberOf nonUi5.element * @description Waits until the element with the given selector is clickable. * @param {Object} selector - The CSS selector describing the element. * @param {Number} [timeout=30000] - The timeout to wait (ms). * @example await nonUi5.element.waitToBeClickable(".input01"); * @example await nonUi5.element.waitToBeClickable("#button12"); * @example await nonUi5.element.waitToBeClickable("p:first-child"); */ waitToBeClickable(selector: any, timeout?: number): Promise<void>; /** * @function getAllDisplayed * @memberOf nonUi5.element * @description Gets all visible elements with the passed selector. * @param {Object} selector - The CSS selector describing the element. * @param {Number} [timeout=30000] - The timeout to wait (ms). * @returns {Object[]} The array of elements. * @example await nonUi5.element.getAllDisplayed(".inputField"); */ getAllDisplayed(selector: any, timeout?: number): Promise<Element[]>; /** * @function getAll * @memberOf nonUi5.element * @description Returns all elements found by the given selector despite visible or not. * @param {Object} selector - The CSS selector describing the element. * @param {Number} [timeout=30000] - The timeout to wait (ms). * @example const hiddenElements = await nonUi5.element.getAll(".sapUiInvisibleText"); * const isPresent = await nonUi5.element.isPresent(hiddenElements[0]); * await common.assertion.expectTrue(isPresent); */ getAll(selector: any, timeout?: number): Promise<Element[]>; /** * @function getByCss * @memberOf nonUi5.element * @description Gets the element with the given CSS selector. * @param {Object} selector - The CSS selector describing the element. * @param {Number} [index=0] - The index of the element (in case there are more than one elements visible at the same time). * @param {Number} [timeout=30000] - The timeout to wait (ms). * @param {Boolean} [includeHidden=false] - Specifies if hidden elements are also considered. By default it checks only for visible ones. * @returns {Object} The found element. * @example const elem = await nonUi5.element.getByCss(".button01"); */ getByCss(selector: any, index?: number, timeout?: number, includeHidden?: boolean): Promise<Element>; /** * @function getByCssContainingText * @memberOf nonUi5.element * @description Gets the element with the given CSS selector containing the given text value. * @param {Object} selector - The CSS selector describing the element. * @param {String} [text=""] - The containing text value of the element. * @param {Number} [index=0] - The index of the element (in case there are more than one elements visible at the same time). * @param {Number} [timeout=30000] - The timeout to wait (ms). * @param {Boolean} [includeHidden=false] - Specifies if hidden elements are also considered. By default it checks only for visible ones. * @param {Boolean} [strict=false] - Specifies if the values match should be exact * @returns {Object} The found element. * @example const elem = await nonUi5.element.getByCssContainingText(".input01", "Jack Jackson"); */ getByCssContainingText(selector: any, text?: string, index?: number, timeout?: number, includeHidden?: boolean, strict?: boolean): Promise<Element>; /** * @function getById * @memberOf nonUi5.element * @description Gets the element with the given ID. * @param {String} id - The id of the element. * @param {Number} [timeout=30000] - The timeout to wait (ms). * @param {Boolean} [includeHidden=false] - Specifies if the function will check for the elements visibility. * @returns {Object} The found element. * @example const elem = await nonUi5.element.getById("button01"); */ getById(id: string, timeout?: number, includeHidden?: boolean): Promise<Element>; /** * @function getByClass * @memberOf nonUi5.element * @description Gets the element with the given class. * @param {String} elemClass - The class describing the element * @param {Number} [index=0] - The index of the element (in case there are more than one elements visible at the same time). * @param {Number} [timeout=30000] - The timeout to wait (ms). * @param {Boolean} [includeHidden=false] - Specifies if hidden elements are also considered. By default it checks only for visible ones. * @returns {Object} The found element. * @example const elem = await nonUi5.element.getByClass("button01"); * const elem = await nonUi5.element.getByClass("sapMIBar sapMTB sapMTBNewFlex sapContrastPlus"); */ getByClass(elemClass: string, index?: number, timeout?: number, includeHidden?: boolean): Promise<Element>; /** * @function getByName * @memberOf nonUi5.element * @description Gets the element with the given name. * @param {String} name - The name attribute of the element. * @param {Number} [index=0] - The index of the element (in case there are more than one elements visible at the same time). * @param {Number} [timeout=30000] - The timeout to wait (ms). * @param {Boolean} [includeHidden=false] - Specifies if hidden elements are also considered. By default it checks only for visible ones. * @returns {Object} The found element. * @example const elem = await nonUi5.element.getByName(".button01"); */ getByName(name: string, index?: number, timeout?: number, includeHidden?: boolean): Promise<Element>; /** * @function getByXPath * @memberOf nonUi5.element * @description Gets the element with the given XPath. * @param {String} xpath - The XPath describing the element. * @param {Number} [index=0] - The index of the element (in case there are more than one elements visible at the same time). * @param {Number} [timeout=30000] - The timeout to wait (ms). * @param {Boolean} [includeHidden=false] - Specifies if hidden elements are also considered. By default it checks only for visible ones. * @returns {Object} The found element. * @example const elem = await nonUi5.element.getByXPath("//ul/li/a"); */ getByXPath(xpath: string, index?: number, timeout?: number, includeHidden?: boolean): Promise<Element>; /** * @function getByChild * @memberOf nonUi5.element * @description Gets an element by its selector and child selector. Can be used when multiple elements have the same properties. * @param {String} elementSelector - The CSS selector describing the element. * @param {String} childSelector - The CSS selector describing the child element. * @param {Number} [index=0] - The index of the element (in case there are more than one elements visible at the same time). * @param {Number} [timeout=30000] - The timeout to wait (ms). * @param {Boolean} [includeHidden=false] - Specifies if hidden elements are also considered. By default it checks only for visible ones. * @returns {Object} The found element. * @example const elem = await nonUi5.element.getByChild(".form01", ".input01"); */ getByChild(elementSelector: any, childSelector: any, index?: number, timeout?: number, includeHidden?: boolean): Promise<Element>; /** * @function getByParent * @memberOf nonUi5.element * @description Gets an element by its selector and parent selector. Can be used when multiple elements have the same properties. * @param {String} elementSelector - The CSS selector describing the element. * @param {String} parentSelector - The CSS selector describing the parent element. * @param {Number} [index=0] - The index of the element (in case there are more than one elements visible at the same time). * @param {Number} [timeout=30000] - The timeout to wait (ms). * @param {Boolean} [includeHidden=false] - Specifies if hidden elements are also considered. By default it checks only for visible ones. * @returns {Object} The found element. * @example const elem = await nonUi5.element.getByParent(".form01", ".input01"); */ getByParent(elementSelector: any, parentSelector: any, index?: number, timeout?: number, includeHidden?: boolean): Promise<Element>; /** * @function isVisible * @memberOf nonUi5.element * @description Returns a boolean if the element is visible to the user. * @param {Object} element - The element. * @param {Boolean} [strict=true] - If strict mode is enabled it will only return "true" if the element is visible on the page and within the viewport. * If disabled, it will be sufficient if the element is visible on the page but not inside the current viewport. * @returns {Boolean} Returns true or false. * @example const elem = await nonUi5.element.getById("button01"); * await nonUi5.element.isVisible(elem); */ isVisible(element: Element, strict?: boolean): Promise<boolean>; /** * @function isPresent * @memberOf nonUi5.element * @description Returns a boolean if the element is present at the DOM or not. It might be hidden. * @param {Object} elem - The element. * @returns {Boolean} Returns true or false. * @example const elem = await nonUi5.element.getById("button01"); * await nonUi5.element.isPresent(elem); */ isPresent(elem: Element): Promise<boolean>; /** * @function isEnabled * @memberOf nonUi5.element * @description Returns a boolean if the element is enabled or not. * @param {Element} elem - The element. * @returns {Boolean} Returns true or false. * @example const elem = await nonUi5.element.getById("button01"); * await nonUi5.element.isEnabled(elem); */ isEnabled(elem: Element): Promise<boolean>; /** * @function isPresentByCss * @memberOf nonUi5.element * @description Returns a boolean if the element is present at the DOM or not. * @param {String} css - The CSS selector describing the element. * @param {Number} [index=0] - The index of the element (in case there are more than one elements visible at the same time). * @param {Number} [timeout=30000] - The timeout to wait (ms). * @returns {boolean} Returns true or false. * @example await nonUi5.element.isPresentByCss(".button01"); */ isPresentByCss(css: string, index?: number, timeout?: number): Promise<boolean>; /** * @function isPresentByXPath * @memberOf nonUi5.element * @description Returns a boolean if the element is present at the DOM or not. * @param {String} xpath - The XPath describing the element. * @param {Number} [index=0] - The index of the element (in case there are more than one elements visible at the same time). * @param {Number} [timeout=30000] - The timeout to wait (ms). * @returns {boolean} * @example await nonUi5.element.isPresentByXPath(".//*[text()='Create']"); */ isPresentByXPath(xpath: string, index?: number, timeout?: number): Promise<boolean>; /** * @function isSelected * @memberOf nonUi5.element * @description Returns a boolean if the element (e.g. checkbox) is selected. * @param {Object} elem - The element. * @returns {boolean} * @example const elem = await nonUi5.element.getById("elem01"); * const isSelected = await nonUi5.element.isSelected(elem); */ isSelected(elem: Element): Promise<boolean>; /** * @function getAttributeValue * @memberOf nonUi5.element * @description Returns the attributes value of the passed element. * @param {Object} elem - The element. * @param {String} [attribute] - The attribute of the element. Leave empty to return the inner HTML value of the element. * @returns {String} The attributes value of the element. * @example const elem = await nonUi5.element.getById("elem01"); * const text = await nonUi5.element.getAttributeValue(elem, "text"); * @example const elem = await nonUi5.element.getById("elem02"); * const innerHTML = await nonUi5.element.getAttributeValue(elem); */ getAttributeValue(elem: Element, attribute?: string): Promise<string>; /** * @function getValue * @memberOf nonUi5.element * @description Returns the value of the passed element. * @param {Object} elem - The element. * @returns {String} The value of the element. * @example const elem = await nonUi5.element.getById("elem02"); * const innerHTML = await nonUi5.element.getValue(elem); */ getValue(elem: Element): Promise<string>; /** * @function getCssPropertyValue * @memberOf nonUi5.element * @description Returns the value of the passed CSS property of the element. * @param {Element | string} elementOrSelector - The element or CSS selector describing the element. * @param {String} cssProperty - The CSS property of the element to get value. * @returns {String} The value of the CSS property. * @example const elem = await nonUi5.element.getById("elem01"); * const color = await nonUi5.element.getCssPropertyValue(elem, "color"); */ getCssPropertyValue(elementOrSelector: Element | string, cssProperty: string): Promise<string>; /** * @function setInnerHTML * @memberOf nonUi5.element * @description Sets the innerHTML value of the given element. * CAUTION: Only use this if filling the value in the normal way is not working and if it is unavoidable. Keep in mind, that a user is not able to perform such actions. * @param {Object} elem - The element. * @returns {String} The value to set. * @example const elem = await nonUi5.element.getById("text-editor"); * await nonUi5.element.setInnerHTML(elem, "Hello World!"); */ setInnerHTML(elem: Element, value: string): Promise<void>; /** * @function highlight * @memberOf nonUi5.element * @description Highlights the passed element. * @param {Object} elem - The element. * @param {Integer} [duration=2000] - The duration of the highlighting (ms). * @param {String} [color="red"] - The color of the highlighting (CSS value). * @example const elem = await nonUi5.element.getById("text01"); * await nonUi5.element.highlight(elem); * @example const elem = await nonUi5.element.getById("text01"); * await nonUi5.element.highlight(elem, 3000, "green"); */ highlight(elem: Element, duration?: number, color?: string): Promise<any>; private _waitForStabilization; private _getAndFilterElementBySelector; private _filterByText; private _filterDisplayed; } declare const _default: ElementModule; export default _default;