function syncOptions() { for (var i in middlewareOptions) { Object.assign( middlewareOptions[i].options, globalOptions, middlewareOptions[i].localOptions, ) } }
async _withinEnd() { if (!isWithin()) return; if (withinStore.frame) { withinStore = {}; return this.switchTo(null); } this.browser.findElement = withinStore.elFn; this.browser.findElements = withinStore.elsFn; withinStore = {}; this.context = this.options.rootElement; }
/** * {{> waitForText }} */ async waitForText(text, sec = null, context = null) { if (!context) { context = this.context; } const el = global.element(guessLocator(context) || global.by.css(context)); const aSec = sec || this.options.waitForTimeout; return this.browser.wait(EC.textToBePresentInElement(el, text), aSec * 1000); }
this.props.variableOptions.forEach(variableOption => { const foundOption = variableOption.options.find(option => this.props.condition.variable === option.value); if (foundOption) { selectedOption = foundOption; } });
get localStorage() { const { context } = this.options; this.assert( `Could not find "localStorage" on the given context "${context}".`, context && context.localStorage ); return context.localStorage; }
handleFeedItems(items) { const nextLength = this.items.length + items.length; if (nextLength >= this.options.maxItemHistory) { const diff = nextLength - this.options.maxHistory; this.items = this.items.splice(0, diff); } this.items = this.items.concat(items); this.options.onNewItems({ feed: this.options, items, }); }
/** * Waits for element to become clickable for number of seconds. * * ```js * I.waitForClickable('#link'); * ``` */ async waitForClickable(locator, sec = null) { const aSec = sec || this.options.waitForTimeout; const el = global.element(guessLocator(locator) || global.by.css(locator)); return this.browser.wait(EC.elementToBeClickable(el), aSec * 1000); }
onDisconnect() { const { context } = this.options; stubbedXhrs.delete(context.XMLHttpRequest); this.xhr.restore(); }
/** * {{> waitForEnabled }} */ async waitForEnabled(locator, sec = null) { const aSec = sec || this.options.waitForTimeout; const el = global.element(guessLocator(locator) || global.by.css(locator)); return this.browser.wait(EC.elementToBeClickable(el), aSec * 1000) .catch((err) => { throw Error(`element (${locator}) still not enabled after ${aSec} sec`); }); }
/** * {{> waitForVisible }} */ async waitForVisible(locator, sec = null) { const aSec = sec || this.options.waitForTimeout; const el = global.element(guessLocator(locator) || global.by.css(locator)); return this.browser.wait(EC.visibilityOf(el), aSec * 1000); }