UNPKG

detox-allure2-adapter

Version:
83 lines 3.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ElementResult = exports.EspressoWebDetox = void 0; const utils_1 = require("../../utils"); class EspressoWebDetox { static getWebView(matcher) { return new GetWebViewResult(matcher); } static expect(webElement) { return new ExpectResult(webElement); } } exports.EspressoWebDetox = EspressoWebDetox; class GetWebViewResult { matcher; constructor(matcher) { this.matcher = matcher; } element(matcher, index) { return new ElementResult(this, matcher, index); } toJSON() { return this.matcher ? (0, utils_1.glue)('WebView ', this.matcher, ':') : (0, utils_1.msg)('WebView:'); } } class ExpectResult { webElement; constructor(webElement) { this.webElement = webElement; } toExist() { return (0, utils_1.concat)(this.webElement.webview, 'Expect', this.webElement.matcher, 'to exist'); } toHaveText(text) { return (0, utils_1.concat)(this.webElement.webview, 'Expect', this.webElement.matcher, (0, utils_1.msg)(`to have text "${text}"`, { expected_text: text })); } toNotExist() { return (0, utils_1.concat)(this.webElement.webview, 'Expect', this.webElement.matcher, 'not to exist'); } } class ElementResult { matcher; webview; constructor(webview, matcher, index) { this.webview = webview; this.matcher = (0, utils_1.glue)(matcher, ElementResult.formatIndex(index)); } static formatIndex(index) { return Number.isFinite(index) ? (0, utils_1.msg)(`[${index}]`, { web_index: index }) : null; } getText() { return (0, utils_1.concat)(this.webview, 'Get text from', this.matcher); } tap() { return (0, utils_1.concat)(this.webview, 'Tap', this.matcher); } replaceText(text) { return (0, utils_1.concat)(this.webview, 'Replace text in', this.matcher, 'with', (0, utils_1.msg)(JSON.stringify(text), { text })); } clearText() { return (0, utils_1.concat)(this.webview, 'Clear text in', this.matcher); } getTitle() { return (0, utils_1.concat)(this.webview, 'Get title of', this.matcher); } typeText(text) { return (0, utils_1.concat)(this.webview, 'Type', (0, utils_1.msg)(JSON.stringify(text), { text }), 'in', this.matcher); } getCurrentUrl() { return (0, utils_1.concat)(this.webview, 'Get current URL from', this.matcher); } runScript(script) { return (0, utils_1.concat)(this.webview, (0, utils_1.msg)('Run script on', { script }), this.matcher); } runScriptWithArgs(script, args) { return (0, utils_1.concat)(this.webview, (0, utils_1.msg)('Run script with args on', { args, script }), this.matcher); } scrollToView() { return (0, utils_1.concat)(this.webview, 'Scroll to', this.matcher); } } exports.ElementResult = ElementResult; //# sourceMappingURL=EspressoWebDetox.js.map