UNPKG

webdriverio

Version:

Next-gen browser and mobile automation test framework for Node.js

38 lines (27 loc) 1.13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _getElementObject = require("../../utils/getElementObject"); var _utils = require("../../utils"); var _constants = require("../../constants"); async function custom$$(strategyName, strategyArguments) { const browserObject = (0, _utils.getBrowserObject)(this); const strategy = browserObject.strategies.get(strategyName); if (!strategy) { throw Error('No strategy found for ' + strategyName); } if (!this.elementId) { throw Error(`Can't call custom$ on element with selector "${this.selector}" because element wasn't found`); } let res = await this.execute(strategy, strategyArguments, this); if (!Array.isArray(res)) { res = [res]; } res = res.filter(el => !!el && typeof el[_constants.ELEMENT_KEY] === 'string'); const elements = res.length ? await _getElementObject.getElements.call(this, strategy, res) : []; return (0, _utils.enhanceElementsArray)(elements, this, strategyName, 'custom$$', [strategyArguments]); } var _default = custom$$; exports.default = _default;