2021-08-21 01:27:10 +08:00
|
|
|
// Common
|
|
|
|
function checkElement(element, index = 0) {
|
|
|
|
return document.querySelectorAll(element)[index] !== undefined;
|
|
|
|
}
|
|
|
|
|
2021-10-20 04:12:00 +08:00
|
|
|
async function closePages(...pages) {
|
|
|
|
for (const page of pages) {
|
|
|
|
await page.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-21 01:27:10 +08:00
|
|
|
// Text
|
|
|
|
function checkElementText(element, param, index = 0) {
|
|
|
|
return document.querySelectorAll(element)[index].innerText === param;
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkElementTextIncludes(element, param, index = 0) {
|
|
|
|
return document.querySelectorAll(element)[index].innerText.includes(param);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getElementText(element, index = 0) {
|
|
|
|
return document.querySelectorAll(element)[index].innerText;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Length
|
|
|
|
function checkElementLengthEqualTo(element, param) {
|
|
|
|
return document.querySelectorAll(element).length === param;
|
|
|
|
}
|
|
|
|
|
|
|
|
function checkElementLengthDifferentTo(element, param) {
|
|
|
|
return document.querySelectorAll(element).length !== param;
|
|
|
|
}
|
|
|
|
|
|
|
|
// use this for other operations
|
|
|
|
function getElementLength(element) {
|
|
|
|
return document.querySelectorAll(element).length;
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.checkElement = checkElement;
|
2021-10-20 04:12:00 +08:00
|
|
|
exports.closePages = closePages;
|
2021-08-21 01:27:10 +08:00
|
|
|
exports.checkElementText = checkElementText;
|
|
|
|
exports.checkElementTextIncludes = checkElementTextIncludes;
|
|
|
|
exports.getElementText = getElementText;
|
|
|
|
exports.checkElementLengthEqualTo = checkElementLengthEqualTo;
|
|
|
|
exports.checkElementLengthDifferentTo = checkElementLengthDifferentTo;
|
2023-04-04 04:23:26 +08:00
|
|
|
exports.getElementLength = getElementLength;
|