webdriverio-automation
Version:
WebdriverIO-Automation android ios project
36 lines (28 loc) • 856 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = findElementFromElement;
var _constants = require("../constants");
var _utils = require("../utils");
async function findElementFromElement({
elementId,
using,
value
}) {
if (!_constants.SUPPORTED_SELECTOR_STRATEGIES.includes(using)) {
throw new Error(`selector strategy "${using}" is not yet supported`);
}
const elementHandle = this.elementStore.get(elementId);
if (!elementHandle) {
throw (0, _utils.getStaleElementError)(elementId);
}
if (using === 'link text') {
using = 'xpath';
value = `.//a[normalize-space() = "${value}"]`;
} else if (using === 'partial link text') {
using = 'xpath';
value = `.//a[contains(., "${value}")]`;
}
return _utils.findElement.call(this, elementHandle, using, value);
}