UNPKG

tia

Version:

Time is All (logs driven test engine with ExtJs support)

79 lines 2.87 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; Object.defineProperty(exports, "__esModule", { value: true }); const path = __importStar(require("path")); const fs = __importStar(require("fs")); const util_1 = require("util"); const utils = __importStar(require("./extjs-utils")); const explore = __importStar(require("./extjs-exploration")); const query = __importStar(require("./new-api/tia-extjs-query")); const msgBox = __importStar(require("./extjs-msgbox")); const wait = __importStar(require("./extjs-waits")); async function setEJSelectors(enableLog) { const objStr = util_1.inspect(gT.globalConfig.ejSelectors, { compact: true, breakLength: 200 }); return gIn.wrap({ msg: 'setEJSelectors ... ', enableLog, act: () => { const scriptStr = `return tiaEJ.setSelectors(${objStr});`; return gT.s.browser.executeScriptWrapper(scriptStr).then(res => { if (res !== true) { throw new Error('setEJSelectors: Unexpected return value'); } }); }, }); } // for gT.e.initTiaExtJsBrHelpers const brHelpers = [ 'e-br.js', 'e-br-actions.js', 'e-br-check.js', 'e-br-cmp-wrappers.js', 'e-br-content.js', 'e-br-get-html-els.js', 'e-br-msgbox.js', 'e-br-search.js', ]; class ExtJsAPI { /** * Initializes TIA ExtJs Browser helpers. * Loads and runs scripts from the extjs/browser-part directory in context of current browser window. * Adds some ExtJs helpers to window object. * * @param {boolean} [enableLog=true] - is logging needed for this action. * * @returns {Promise}. */ static initTiaExtJsBrHelpers(enableLog) { return gIn.wrap({ msg: 'Initialization of TIA ExtJs helpers ... ', enableLog, act: async () => { for (const fName of brHelpers) { // eslint-disable-line no-restricted-syntax const scriptStr = fs.readFileSync(path.join(gT.tiaDir, 'src', 'api', 'extjs', 'browser-part', fName), 'utf8'); await gT.s.browser.executeScriptWrapper(scriptStr); } await setEJSelectors(enableLog); if (gT.cLParams.debugLocale) { await gT.e.utils.setDebugLocaleMode(true); } }, }); } } ExtJsAPI.utils = utils; ExtJsAPI.explore = explore; ExtJsAPI.msgBox = msgBox; ExtJsAPI.wait = wait; ExtJsAPI.query = query; ExtJsAPI.q = query; exports.ExtJsAPI = ExtJsAPI; //# sourceMappingURL=extjs-index.js.map