tia
Version:
Time is All (logs driven test engine with ExtJs support)
252 lines • 8.68 kB
JavaScript
;
/* eslint-disable no-param-reassign */
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Clicks to element specified by id.
*
* @param id
* @param enableLog - enable/disable logging for this action.
* @returns {Promise.<TResult>}
*/
function clickById(id, enableLog) {
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Click on element ${idObj.logStr} ... `,
enableLog,
act: async () => {
// await gT.s.wait.waitForElementEnabledAndVisibleById(
// id,
// gT.engineConsts.defaultWaitTimeout,
// false,
// );
await gT.sOrig.driver.findElement(gT.sOrig.by.id(idObj.id)).click();
},
});
}
exports.clickById = clickById;
/**
* Right Click to element specified by id.
*
* @param id
* @param enableLog - enable/disable logging for this action.
* @returns {Promise.<TResult>}
*/
function rClickById(id, enableLog) {
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Right Click on element ${idObj.logStr} ... `,
enableLog,
act: async () => {
// await gT.s.wait.waitForElementEnabledAndVisibleById(
// id,
// gT.engineConsts.defaultWaitTimeout,
// false,
// );
const el = await gT.sOrig.driver.findElement(gT.sOrig.by.id(idObj.id));
await gT.sOrig.driver
.actions({ bridge: true })
.contextClick(el)
.perform();
},
});
}
exports.rClickById = rClickById;
/**
* Left mouse button double click to element specified by id.
*
* @param id
* @param enableLog - enable/disable logging for this action.
* @returns {Promise.<TResult>}
*/
function dblClickById(id, enableLog) {
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Double Click on element ${idObj.logStr} ... `,
enableLog,
act: async () => {
// await gT.s.wait.waitForElementEnabledAndVisibleById(
// id,
// gT.engineConsts.defaultWaitTimeout,
// false,
// );
const el = await gT.sOrig.driver.findElement(gT.sOrig.by.id(idObj.id));
await gT.sOrig.driver
.actions({ bridge: true })
.doubleClick(el)
.perform();
},
});
}
exports.dblClickById = dblClickById;
function sendEscById(id, enableLog) {
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Send Esc to element ${idObj.logStr} ... `,
enableLog,
act: () => gT.sOrig.driver.findElement(gT.sOrig.by.id(idObj.id)).sendKeys(gT.sOrig.key.ESCAPE),
});
}
exports.sendEscById = sendEscById;
function sendDownById(id, enableLog) {
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Send DOWN to element ${idObj.logStr} ... `,
enableLog,
act: () => gT.sOrig.driver.findElement(gT.sOrig.by.id(idObj.id)).sendKeys(gT.sOrig.key.DOWN),
});
}
exports.sendDownById = sendDownById;
function sendEnterById(id, enableLog) {
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Send ENTER to element ${idObj.logStr} ... `,
enableLog,
act: () => gT.sOrig.driver.findElement(gT.sOrig.by.id(idObj.id)).sendKeys(gT.sOrig.key.ENTER),
});
}
exports.sendEnterById = sendEnterById;
function sendTabById(id, enableLog) {
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Send TAB to element ${idObj.logStr} ... `,
enableLog,
act: () => gT.sOrig.driver.findElement(gT.sOrig.by.id(idObj.id)).sendKeys(gT.sOrig.key.TAB),
});
}
exports.sendTabById = sendTabById;
function sendPgDownById(id, enableLog) {
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Send PAGE_DOWN to element ${idObj.logStr} ... `,
enableLog,
act: () => gT.sOrig.driver.findElement(gT.sOrig.by.id(idObj.id)).sendKeys(gT.sOrig.key.PAGE_DOWN),
});
}
exports.sendPgDownById = sendPgDownById;
function sendPgUpById(id, enableLog) {
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Send PAGE_UP to element ${idObj.logStr} ... `,
enableLog,
act: () => gT.sOrig.driver.findElement(gT.sOrig.by.id(idObj.id)).sendKeys(gT.sOrig.key.PAGE_UP),
});
}
exports.sendPgUpById = sendPgUpById;
function sendUpById(id, enableLog) {
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Send UP to element ${idObj.logStr} ... `,
enableLog,
act: () => gT.sOrig.driver.findElement(gT.sOrig.by.id(idObj.id)).sendKeys(gT.sOrig.key.UP),
});
}
exports.sendUpById = sendUpById;
/**
* Send keys to the web element with specified id.
*
* @param id
* @param keys
* @param enableLog
* @returns {Promise.<TResult>}
*/
function sendKeysById(id, keys, enableLog) {
const selKeys = Array.isArray(keys) ? keys : [keys];
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Send keys: "${selKeys}", to element ${idObj.logStr} ... `,
enableLog,
act: () => gT.sOrig.driver.findElement(gT.sOrig.by.id(idObj.id)).sendKeys(...selKeys),
});
}
exports.sendKeysById = sendKeysById;
function sendCtrlAAndKeysById(id, keys, enableLog) {
const selKeys = Array.isArray(keys) ? keys : [keys];
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Send Ctrl + a and keys: "${selKeys}", to element ${idObj.logStr} ... `,
enableLog,
act: () => gT.sOrig.driver
.findElement(gT.sOrig.by.id(idObj.id))
.sendKeys(gT.sOrig.key.CONTROL, 'a', gT.sOrig.key.NULL, ...selKeys),
});
}
exports.sendCtrlAAndKeysById = sendCtrlAAndKeysById;
function sendCtrlAKeysEnterById(id, keys, enableLog) {
const selKeys = Array.isArray(keys) ? keys : [keys];
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Send Ctrl + A, keys, ENTER: "${selKeys}", to element ${idObj.logStr} ... `,
enableLog,
act: () => gT.sOrig.driver
.findElement(gT.sOrig.by.id(idObj.id))
.sendKeys(gT.sOrig.key.CONTROL, 'a', gT.sOrig.key.NULL, ...selKeys, gT.sOrig.key.ENTER),
});
}
exports.sendCtrlAKeysEnterById = sendCtrlAKeysEnterById;
function sendCtrlAAndDeleteById(id, enableLog) {
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Send Ctrl + a and press DELETE for element ${idObj.logStr} ... `,
enableLog,
act: () => gT.sOrig.driver
.findElement(gT.sOrig.by.id(idObj.id))
.sendKeys(gT.sOrig.key.CONTROL, 'a', gT.sOrig.key.NULL, gT.sOrig.key.DELETE, gT.sOrig.key.NULL),
});
}
exports.sendCtrlAAndDeleteById = sendCtrlAAndDeleteById;
function clearById(id, enableLog) {
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Clear element ${idObj.logStr} ... `,
enableLog,
act: () => gT.sOrig.driver.findElement(gT.sOrig.by.id(idObj.id)).clear(),
});
}
exports.clearById = clearById;
function sendKeysToBody(keys, enableLog) {
const selKeys = Array.isArray(keys) ? keys : [keys];
return gIn.wrap({
msg: `Send keys: "${selKeys}", to body ... `,
enableLog,
act: () => gT.sOrig.driver.findElement(gT.sOrig.by.css('body')).sendKeys(...selKeys),
});
}
exports.sendKeysToBody = sendKeysToBody;
function moveMouse(webElement, enableLog) {
return gIn.wrap({
msg: `Move mouse to element with id "${webElement.getId()}" ... `,
enableLog,
act: async () => {
await gT.sOrig.driver
.actions({ bridge: true })
.move({
duration: gT.engineConsts.moveDuration,
origin: webElement,
x: 0,
y: 0,
})
.perform();
},
});
}
exports.moveMouse = moveMouse;
function moveMouseById(id, enableLog) {
const idObj = gT.s.idToIdForLogObj(id);
return gIn.wrap({
msg: `Move mouse to element with id "${idObj.logStr}" ... `,
enableLog,
act: async () => {
await gT.sOrig.driver
.actions({ bridge: true })
.move({
duration: gT.engineConsts.moveDuration,
origin: gT.sOrig.driver.findElement(gT.sOrig.by.id(idObj.id)),
x: 0,
y: 0,
})
.perform();
},
});
}
exports.moveMouseById = moveMouseById;
//# sourceMappingURL=sel-user-actions.js.map