@zeesoft/i18n-verify 3.3.7 → 3.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/executor.mjs +78 -43
- package/package.json +1 -1
package/dist/executor.mjs
CHANGED
|
@@ -302,7 +302,7 @@ const pathExists = (path2) => existsSync(path2);
|
|
|
302
302
|
const createFolder = (path2) => !pathExists(path2) && mkdirSync(path2, { recursive: true });
|
|
303
303
|
const ensureDirectoryExists = (path2, log2 = true) => {
|
|
304
304
|
if (!pathExists(path2) || !dirExists(path2)) {
|
|
305
|
-
log2 && Logger.debug(`Folder doesn't exists, creating \x1B[34m${path2}\x1B[0m`);
|
|
305
|
+
log2 && Logger$1.debug(`Folder doesn't exists, creating \x1B[34m${path2}\x1B[0m`);
|
|
306
306
|
createFolder(path2);
|
|
307
307
|
}
|
|
308
308
|
};
|
|
@@ -321,7 +321,7 @@ const addContentToFile = (path2, content, encoding = "utf-8") => {
|
|
|
321
321
|
flag: "a"
|
|
322
322
|
});
|
|
323
323
|
} catch (err) {
|
|
324
|
-
Logger.error(err);
|
|
324
|
+
Logger$1.error(err);
|
|
325
325
|
}
|
|
326
326
|
};
|
|
327
327
|
const getDirPath = (filePath) => dirname(filePath);
|
|
@@ -426,7 +426,7 @@ class BaseReport {
|
|
|
426
426
|
export(path2, name = DEFAULT_REPORT_NAME) {
|
|
427
427
|
this.write(path2, name, this.$generatedContent);
|
|
428
428
|
const runMode = Config.getMode();
|
|
429
|
-
Logger.info(
|
|
429
|
+
Logger$1.info(
|
|
430
430
|
`Exported consolidated ${runMode} Verification ${this.$type} report in ${path2}`
|
|
431
431
|
);
|
|
432
432
|
}
|
|
@@ -4188,7 +4188,7 @@ class TableReport extends BaseReport {
|
|
|
4188
4188
|
if (this.#hasData) {
|
|
4189
4189
|
this.#printer.printTable();
|
|
4190
4190
|
} else {
|
|
4191
|
-
Logger.info("There are no visible elements with UI strings");
|
|
4191
|
+
Logger$1.info("There are no visible elements with UI strings");
|
|
4192
4192
|
}
|
|
4193
4193
|
}
|
|
4194
4194
|
}
|
|
@@ -5070,21 +5070,21 @@ class Reports {
|
|
|
5070
5070
|
Reports.#generateReport(SUPPORTED_REPORT_TYPES.ASCII_TABLE);
|
|
5071
5071
|
}
|
|
5072
5072
|
}
|
|
5073
|
-
|
|
5073
|
+
let Logger$1 = class Logger2 {
|
|
5074
5074
|
static #isLogAppending = false;
|
|
5075
5075
|
static #appenderInterval;
|
|
5076
5076
|
static #appenderQueue = [];
|
|
5077
5077
|
static info(message) {
|
|
5078
|
-
|
|
5078
|
+
Logger2.#print("info", message);
|
|
5079
5079
|
}
|
|
5080
5080
|
static warn(message) {
|
|
5081
|
-
|
|
5081
|
+
Logger2.#print("warn", message);
|
|
5082
5082
|
}
|
|
5083
5083
|
static error(message, err) {
|
|
5084
|
-
|
|
5084
|
+
Logger2.#print("errr", message, err);
|
|
5085
5085
|
}
|
|
5086
5086
|
static debug(message) {
|
|
5087
|
-
|
|
5087
|
+
Logger2.#print("dbug", message);
|
|
5088
5088
|
}
|
|
5089
5089
|
static #print(type, message, additionalObj = "") {
|
|
5090
5090
|
if (type === "dbug" && !Config.isDebugMode()) {
|
|
@@ -5118,32 +5118,32 @@ class Logger {
|
|
|
5118
5118
|
console.log(logMessage);
|
|
5119
5119
|
}
|
|
5120
5120
|
logMessage = logMessage.replace(/\x1b\[\d+m/g, "");
|
|
5121
|
-
|
|
5121
|
+
Logger2.#customLog(`${logMessage}
|
|
5122
5122
|
`);
|
|
5123
5123
|
}
|
|
5124
5124
|
static #customLog = (message) => {
|
|
5125
|
-
if (
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
if (!
|
|
5129
|
-
clearInterval(
|
|
5130
|
-
message =
|
|
5131
|
-
|
|
5132
|
-
message &&
|
|
5125
|
+
if (Logger2.#isLogAppending) {
|
|
5126
|
+
Logger2.#appenderQueue.push(message);
|
|
5127
|
+
Logger2.#appenderInterval = setInterval(() => {
|
|
5128
|
+
if (!Logger2.#isLogAppending) {
|
|
5129
|
+
clearInterval(Logger2.#appenderInterval);
|
|
5130
|
+
message = Logger2.#appenderQueue.join("\n");
|
|
5131
|
+
Logger2.#appenderQueue = [];
|
|
5132
|
+
message && Logger2.#customLog(message);
|
|
5133
5133
|
}
|
|
5134
5134
|
}, 10);
|
|
5135
5135
|
} else {
|
|
5136
|
-
|
|
5136
|
+
Logger2.#isLogAppending = true;
|
|
5137
5137
|
const logsDir = joinPaths(Reports.getReportPath(), "logs");
|
|
5138
5138
|
if (logsDir) {
|
|
5139
5139
|
const logFilePath = joinPaths(logsDir, "log");
|
|
5140
5140
|
ensureDirectoryExists(logsDir, Config.isDebugMode());
|
|
5141
5141
|
fs.appendFileSync(logFilePath, message);
|
|
5142
5142
|
}
|
|
5143
|
-
|
|
5143
|
+
Logger2.#isLogAppending = false;
|
|
5144
5144
|
}
|
|
5145
5145
|
};
|
|
5146
|
-
}
|
|
5146
|
+
};
|
|
5147
5147
|
class NightWatchDriver extends BaseDriver {
|
|
5148
5148
|
constructor(driver) {
|
|
5149
5149
|
super(driver);
|
|
@@ -5229,7 +5229,13 @@ class NightWatchDriver extends BaseDriver {
|
|
|
5229
5229
|
return eleStr;
|
|
5230
5230
|
}
|
|
5231
5231
|
async captureScreenshot(file) {
|
|
5232
|
-
|
|
5232
|
+
const browserNameRaw = this.$driver.capabilities?.browserName;
|
|
5233
|
+
const browserNames = Array.isArray(browserNameRaw) ? browserNameRaw.map((b) => b?.toLowerCase?.()) : [browserNameRaw?.toLowerCase?.()];
|
|
5234
|
+
if (browserNames.includes("chrome") || browserNames.includes("chromium")) {
|
|
5235
|
+
await captureFullPage$1(this.$driver, file);
|
|
5236
|
+
} else {
|
|
5237
|
+
await captureScreenshotFallback$1(this.$driver, file);
|
|
5238
|
+
}
|
|
5233
5239
|
}
|
|
5234
5240
|
async getElementsCount(elements) {
|
|
5235
5241
|
return elements.length;
|
|
@@ -5297,9 +5303,22 @@ const captureFullPage$1 = async (driver, filePath) => {
|
|
|
5297
5303
|
});
|
|
5298
5304
|
const screenshotBuffer = Buffer.from(data2, "base64");
|
|
5299
5305
|
writeFileSync(filePath, screenshotBuffer);
|
|
5300
|
-
Logger.debug(`Screenshot saved as: ${filePath}`);
|
|
5306
|
+
Logger$1.debug(`Screenshot saved as: ${filePath}`);
|
|
5301
5307
|
await client.close();
|
|
5302
5308
|
};
|
|
5309
|
+
const captureScreenshotFallback$1 = async (driver, filePath) => {
|
|
5310
|
+
const screenshot = await new Promise((resolve2, reject) => {
|
|
5311
|
+
driver.screenshot(function(result) {
|
|
5312
|
+
if (result.status === 0) {
|
|
5313
|
+
resolve2(result.value);
|
|
5314
|
+
} else {
|
|
5315
|
+
reject(new Error("Screenshot capture failed"));
|
|
5316
|
+
}
|
|
5317
|
+
});
|
|
5318
|
+
});
|
|
5319
|
+
writeFileSync(filePath, Buffer.from(screenshot, "base64"));
|
|
5320
|
+
Logger$1.debug(`Screenshot saved as: ${filePath}`);
|
|
5321
|
+
};
|
|
5303
5322
|
const getRemoteDebuggerPort$1 = (driver) => {
|
|
5304
5323
|
const debuggerAddress = driver?.capabilities?.["goog:chromeOptions"]?.debuggerAddress;
|
|
5305
5324
|
if (debuggerAddress) {
|
|
@@ -5388,7 +5407,13 @@ class WebDriverIoDriver extends BaseDriver {
|
|
|
5388
5407
|
return eleStr;
|
|
5389
5408
|
}
|
|
5390
5409
|
async captureScreenshot(file) {
|
|
5391
|
-
|
|
5410
|
+
const browserNameRaw = this.$driver.capabilities?.browserName;
|
|
5411
|
+
const browserNames = Array.isArray(browserNameRaw) ? browserNameRaw.map((b) => b?.toLowerCase?.()) : [browserNameRaw?.toLowerCase?.()];
|
|
5412
|
+
if (browserNames.includes("chrome") || browserNames.includes("chromium")) {
|
|
5413
|
+
await captureFullPage(this.$driver, file);
|
|
5414
|
+
} else {
|
|
5415
|
+
await captureScreenshotFallback(this.$driver, file);
|
|
5416
|
+
}
|
|
5392
5417
|
}
|
|
5393
5418
|
async getElementsCount(elements) {
|
|
5394
5419
|
return elements.length;
|
|
@@ -5442,6 +5467,11 @@ const captureFullPage = async (driver, filePath) => {
|
|
|
5442
5467
|
fs.writeFileSync(filePath, Buffer.from(data2, "base64"));
|
|
5443
5468
|
await client.close();
|
|
5444
5469
|
};
|
|
5470
|
+
const captureScreenshotFallback = async (driver, filePath) => {
|
|
5471
|
+
const screenshot = await driver.takeScreenshot();
|
|
5472
|
+
fs.writeFileSync(filePath, Buffer.from(screenshot, "base64"));
|
|
5473
|
+
Logger.debug(`Screenshot saved as: ${filePath}`);
|
|
5474
|
+
};
|
|
5445
5475
|
const getRemoteDebuggerPort = (driver) => {
|
|
5446
5476
|
const debuggerAddress = driver.capabilities?.["goog:chromeOptions"]?.debuggerAddress;
|
|
5447
5477
|
return debuggerAddress ? debuggerAddress.split(":")[1] || 9229 : 9229;
|
|
@@ -5645,7 +5675,7 @@ class CypressDriver extends BaseDriver {
|
|
|
5645
5675
|
}
|
|
5646
5676
|
}
|
|
5647
5677
|
async captureScreenshot(file) {
|
|
5648
|
-
this.$driver.screenshot(file);
|
|
5678
|
+
await this.$driver.screenshot(file);
|
|
5649
5679
|
}
|
|
5650
5680
|
async getElementsCount(el) {
|
|
5651
5681
|
return new Promise((res) => {
|
|
@@ -5671,7 +5701,7 @@ class CypressDriver extends BaseDriver {
|
|
|
5671
5701
|
}
|
|
5672
5702
|
});
|
|
5673
5703
|
} catch (textError) {
|
|
5674
|
-
Logger.error("Error getting text of element:", textError);
|
|
5704
|
+
Logger$1.error("Error getting text of element:", textError);
|
|
5675
5705
|
}
|
|
5676
5706
|
return elementStrings;
|
|
5677
5707
|
}
|
|
@@ -5747,6 +5777,11 @@ class SeleniumDriver extends BaseDriver {
|
|
|
5747
5777
|
async getElementsCount(elements) {
|
|
5748
5778
|
return elements.length;
|
|
5749
5779
|
}
|
|
5780
|
+
async captureScreenshot(file) {
|
|
5781
|
+
const fs2 = require("fs");
|
|
5782
|
+
const screenshot = await this.$driver.takeScreenshot();
|
|
5783
|
+
fs2.writeFileSync(file, screenshot, "base64");
|
|
5784
|
+
}
|
|
5750
5785
|
}
|
|
5751
5786
|
const build$1 = (type, driver) => {
|
|
5752
5787
|
switch (type) {
|
|
@@ -6032,7 +6067,7 @@ const toLuxonLocale = (locale) => {
|
|
|
6032
6067
|
locale = locale.replace("_", "-");
|
|
6033
6068
|
return Intl.DateTimeFormat.supportedLocalesOf(locale)[0];
|
|
6034
6069
|
} catch (ex) {
|
|
6035
|
-
Logger.warn(`${locale} is unsupported by Intl`);
|
|
6070
|
+
Logger$1.warn(`${locale} is unsupported by Intl`);
|
|
6036
6071
|
return false;
|
|
6037
6072
|
}
|
|
6038
6073
|
};
|
|
@@ -6829,7 +6864,7 @@ class Config {
|
|
|
6829
6864
|
Config.#isDebugMode = config?.debug ?? false;
|
|
6830
6865
|
Config.getGarbledChars();
|
|
6831
6866
|
} catch (ex) {
|
|
6832
|
-
Logger.error(ex.message);
|
|
6867
|
+
Logger$1.error(ex.message);
|
|
6833
6868
|
throw ex;
|
|
6834
6869
|
}
|
|
6835
6870
|
}
|
|
@@ -6985,7 +7020,7 @@ class BaseRunner {
|
|
|
6985
7020
|
await this.#executePageProcess();
|
|
6986
7021
|
}
|
|
6987
7022
|
} catch (ex) {
|
|
6988
|
-
Logger.error("unable to run the process", ex);
|
|
7023
|
+
Logger$1.error("unable to run the process", ex);
|
|
6989
7024
|
} finally {
|
|
6990
7025
|
await this.#postRun();
|
|
6991
7026
|
}
|
|
@@ -7008,10 +7043,10 @@ class BaseRunner {
|
|
|
7008
7043
|
async captureScreen(imagePath) {
|
|
7009
7044
|
try {
|
|
7010
7045
|
await this.#driver.captureScreenshot(imagePath);
|
|
7011
|
-
Logger.debug("reviewed image has been saved");
|
|
7046
|
+
Logger$1.debug("reviewed image has been saved");
|
|
7012
7047
|
return true;
|
|
7013
7048
|
} catch (ex) {
|
|
7014
|
-
Logger.error("unable to capture screenshot");
|
|
7049
|
+
Logger$1.error("unable to capture screenshot");
|
|
7015
7050
|
return false;
|
|
7016
7051
|
}
|
|
7017
7052
|
}
|
|
@@ -7048,7 +7083,7 @@ class BaseRunner {
|
|
|
7048
7083
|
await this.#processLocatorElements();
|
|
7049
7084
|
await this.#processIFrames();
|
|
7050
7085
|
} else {
|
|
7051
|
-
Logger.debug("No locators provided");
|
|
7086
|
+
Logger$1.debug("No locators provided");
|
|
7052
7087
|
}
|
|
7053
7088
|
}
|
|
7054
7089
|
async #executePageProcess() {
|
|
@@ -7107,19 +7142,19 @@ class BaseRunner {
|
|
|
7107
7142
|
}
|
|
7108
7143
|
}
|
|
7109
7144
|
if (!hasElements) {
|
|
7110
|
-
Logger.debug("No UI elements found from the provided locators");
|
|
7145
|
+
Logger$1.debug("No UI elements found from the provided locators");
|
|
7111
7146
|
}
|
|
7112
7147
|
}
|
|
7113
7148
|
async #processIFrames() {
|
|
7114
7149
|
if (await this.#driver.checkIfIframeIsPresent()) {
|
|
7115
7150
|
const frames = await this.#driver.getElements("//iframe");
|
|
7116
|
-
Logger.debug(
|
|
7151
|
+
Logger$1.debug(
|
|
7117
7152
|
`Total ${frames.length} iframes are located on the ${this.#description}`
|
|
7118
7153
|
);
|
|
7119
7154
|
for (let fID = 0; fID < frames.length; fID++) {
|
|
7120
7155
|
const frame = frames[fID];
|
|
7121
7156
|
const offsets = await this.getElementOffsets(frame);
|
|
7122
|
-
Logger.debug(`Switching to iFrame: ${fID}`);
|
|
7157
|
+
Logger$1.debug(`Switching to iFrame: ${fID}`);
|
|
7123
7158
|
await this.#driver.switchToIFrame(fID, frame);
|
|
7124
7159
|
this.#driver.pause(1);
|
|
7125
7160
|
const iframeBody = await this.#driver.getElement("//body");
|
|
@@ -7137,7 +7172,7 @@ class BaseRunner {
|
|
|
7137
7172
|
}
|
|
7138
7173
|
}
|
|
7139
7174
|
}
|
|
7140
|
-
!hasAtLeastOneString && Logger.debug("No valid UI elements found in the iFrame");
|
|
7175
|
+
!hasAtLeastOneString && Logger$1.debug("No valid UI elements found in the iFrame");
|
|
7141
7176
|
await this.#driver.switchToParentFrame();
|
|
7142
7177
|
}
|
|
7143
7178
|
}
|
|
@@ -7150,7 +7185,7 @@ class BaseRunner {
|
|
|
7150
7185
|
try {
|
|
7151
7186
|
await this.process(string, element, offsets, frameId);
|
|
7152
7187
|
} catch (ex) {
|
|
7153
|
-
Logger.error(
|
|
7188
|
+
Logger$1.error(
|
|
7154
7189
|
`unable to process the ${frameId ? `iframe-[${frameId}] ` : ""}string "${string}"`,
|
|
7155
7190
|
ex
|
|
7156
7191
|
);
|
|
@@ -7203,7 +7238,7 @@ class ContextRunner extends BaseRunner {
|
|
|
7203
7238
|
this.getBaseImageName(),
|
|
7204
7239
|
this.getDescription()
|
|
7205
7240
|
);
|
|
7206
|
-
Logger.debug(`context creation for "${string}"`);
|
|
7241
|
+
Logger$1.debug(`context creation for "${string}"`);
|
|
7207
7242
|
await this.#addToContext(string, element, offsets);
|
|
7208
7243
|
}
|
|
7209
7244
|
/**
|
|
@@ -7294,12 +7329,12 @@ class Graphic {
|
|
|
7294
7329
|
const targetDir = path.dirname(report_img);
|
|
7295
7330
|
const buffer = await image.getBufferAsync(Jimp.MIME_PNG);
|
|
7296
7331
|
if (!fs.existsSync(targetDir)) {
|
|
7297
|
-
Logger.debug("folder not found");
|
|
7332
|
+
Logger$1.debug("folder not found");
|
|
7298
7333
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
7299
7334
|
}
|
|
7300
7335
|
fs.writeFileSync(report_img, buffer);
|
|
7301
7336
|
} catch (err) {
|
|
7302
|
-
Logger.error(`Error: ${err}`);
|
|
7337
|
+
Logger$1.error(`Error: ${err}`);
|
|
7303
7338
|
}
|
|
7304
7339
|
}
|
|
7305
7340
|
static async drawRectangleOutline(image, x, y, width, height, color, thickness) {
|
|
@@ -7381,7 +7416,7 @@ class I18nRunner extends BaseRunner {
|
|
|
7381
7416
|
await Graphic.drawRectangle(elRec, color, image);
|
|
7382
7417
|
}
|
|
7383
7418
|
#defineColor(status, string) {
|
|
7384
|
-
Logger.debug(
|
|
7419
|
+
Logger$1.debug(
|
|
7385
7420
|
`"${string}" - ${STATUS_COLOR[status][1]}${STATUS_INFO[status]}${"\x1B[0m"}`
|
|
7386
7421
|
);
|
|
7387
7422
|
return STATUS_COLOR[status][0];
|
|
@@ -7402,7 +7437,7 @@ class SanityRunner extends BaseRunner {
|
|
|
7402
7437
|
* @override
|
|
7403
7438
|
*/
|
|
7404
7439
|
async process(page) {
|
|
7405
|
-
Logger.info(`${page} loaded`);
|
|
7440
|
+
Logger$1.info(`${page} loaded`);
|
|
7406
7441
|
const src_img = joinPaths(
|
|
7407
7442
|
Reports.reviewedReports(page, this.getBaseImageName()),
|
|
7408
7443
|
this.getBaseImageName()
|
|
@@ -7486,7 +7521,7 @@ class Executor {
|
|
|
7486
7521
|
export {
|
|
7487
7522
|
Config as C,
|
|
7488
7523
|
Executor as E,
|
|
7489
|
-
Logger as L,
|
|
7524
|
+
Logger$1 as L,
|
|
7490
7525
|
Reports as R,
|
|
7491
7526
|
SYSTEM_TYPES as S,
|
|
7492
7527
|
getRootProjectMainDir as a,
|
package/package.json
CHANGED