@zeesoft/i18n-verify 2.0.0 → 2.0.2
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.
|
@@ -40,20 +40,14 @@ class NightWatchDriver extends _baseDriver.default {
|
|
|
40
40
|
async getValue(element) {
|
|
41
41
|
return await element.getAttribute('value');
|
|
42
42
|
}
|
|
43
|
-
async getElementID(element) {
|
|
44
|
-
return await element.getAttribute('id');
|
|
45
|
-
}
|
|
46
43
|
async getElementDimension(element) {
|
|
47
44
|
const eleSize = await element.getRect();
|
|
48
45
|
if (![null, '', undefined].includes(eleSize)) {
|
|
49
46
|
return [eleSize.x, eleSize.y, eleSize.height, eleSize.width];
|
|
50
47
|
}
|
|
51
48
|
}
|
|
52
|
-
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
async isElementPresent(element) {
|
|
56
|
-
return await this.$driver.isPresent(element);
|
|
49
|
+
isElementDisplayed(element) {
|
|
50
|
+
return this.$driver.isVisible(element);
|
|
57
51
|
}
|
|
58
52
|
async getElementStrings(element) {
|
|
59
53
|
const elementStrings = [];
|
|
@@ -97,38 +91,5 @@ class NightWatchDriver extends _baseDriver.default {
|
|
|
97
91
|
async getElementsCount(elements) {
|
|
98
92
|
return elements.length;
|
|
99
93
|
}
|
|
100
|
-
async switchFrame(frameID) {
|
|
101
|
-
if (frameID && frameID !== '') {
|
|
102
|
-
await this.$driver.frame(frameID, () => {
|
|
103
|
-
console.log(`Switching to iframe '${frameID}'`);
|
|
104
|
-
});
|
|
105
|
-
} else {
|
|
106
|
-
await this.$driver.frame(() => {
|
|
107
|
-
console.log('Switching to parentFrame');
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
pause(time) {
|
|
112
|
-
this.$driver.pause(time * 1000);
|
|
113
|
-
}
|
|
114
|
-
async onScreenStringHighlight(el, color) {
|
|
115
|
-
await this.$driver.execute((el, color) => {
|
|
116
|
-
el.style.border = `3px solid ${color}`;
|
|
117
|
-
setTimeout(() => {
|
|
118
|
-
el.style.border = 'none';
|
|
119
|
-
}, 50);
|
|
120
|
-
}, [el, color]);
|
|
121
|
-
}
|
|
122
|
-
async checkIfIframeIsPresent() {
|
|
123
|
-
return new Promise(res => {
|
|
124
|
-
this.$driver.isPresent({
|
|
125
|
-
selector: '//iframe',
|
|
126
|
-
locateStrategy: 'xpath',
|
|
127
|
-
suppressNotFoundErrors: true
|
|
128
|
-
}, result => {
|
|
129
|
-
res(result.value);
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
94
|
}
|
|
134
95
|
exports.default = NightWatchDriver;
|
|
@@ -47,15 +47,9 @@ class BaseDriver {
|
|
|
47
47
|
getElementDimension() {
|
|
48
48
|
throw new Error('implementation is missing');
|
|
49
49
|
}
|
|
50
|
-
getElementID() {
|
|
51
|
-
throw new Error('implementation is missing');
|
|
52
|
-
}
|
|
53
50
|
isElementDisplayed() {
|
|
54
51
|
throw new Error('implementation is missing');
|
|
55
52
|
}
|
|
56
|
-
isElementPresent() {
|
|
57
|
-
throw new Error('implementation is missing');
|
|
58
|
-
}
|
|
59
53
|
getElementString() {
|
|
60
54
|
throw new Error('implementation is missing');
|
|
61
55
|
}
|
|
@@ -68,18 +62,6 @@ class BaseDriver {
|
|
|
68
62
|
getElementsCount() {
|
|
69
63
|
throw new Error('implementation is missing');
|
|
70
64
|
}
|
|
71
|
-
switchFrame() {
|
|
72
|
-
throw new Error('implementation is missing');
|
|
73
|
-
}
|
|
74
|
-
pause() {
|
|
75
|
-
throw new Error('implementation is missing');
|
|
76
|
-
}
|
|
77
|
-
onScreenStringHighlight() {
|
|
78
|
-
throw new Error('implementation is missing');
|
|
79
|
-
}
|
|
80
|
-
checkIfIframeIsPresent() {
|
|
81
|
-
throw new Error('implementation is missing');
|
|
82
|
-
}
|
|
83
65
|
printOnConsole(str) {
|
|
84
66
|
console.log(str);
|
|
85
67
|
}
|
package/dist/lib/i18n.js
CHANGED
|
@@ -8,7 +8,7 @@ var _baseDriver = _interopRequireDefault(require("../driver/baseDriver.js"));
|
|
|
8
8
|
var _constants = require("../utils/constants.js");
|
|
9
9
|
var _config = _interopRequireDefault(require("./config.js"));
|
|
10
10
|
var _reports = _interopRequireDefault(require("../utils/reports.js"));
|
|
11
|
-
var
|
|
11
|
+
var _graphic = _interopRequireDefault(require("../utils/graphic.js"));
|
|
12
12
|
var _logs = _interopRequireDefault(require("../utils/logs.js"));
|
|
13
13
|
var _fs = _interopRequireDefault(require("fs"));
|
|
14
14
|
var _file = require("../utils/file.js");
|
|
@@ -68,18 +68,12 @@ class I18nVerify {
|
|
|
68
68
|
}
|
|
69
69
|
async #getElement(verificationArea, locator, img_name, desc) {
|
|
70
70
|
const ele = await this.#driver.getElement(locator);
|
|
71
|
-
if (ele && (await this.#driver.
|
|
71
|
+
if (ele && (await this.#driver.isElementDisplayed(ele))) {
|
|
72
72
|
let str;
|
|
73
73
|
try {
|
|
74
74
|
str = await this.#driver.getElementString(ele);
|
|
75
75
|
try {
|
|
76
|
-
await this.#generateReports(
|
|
77
|
-
verificationArea,
|
|
78
|
-
ele,
|
|
79
|
-
img_name,
|
|
80
|
-
str,
|
|
81
|
-
desc
|
|
82
|
-
});
|
|
76
|
+
await this.#generateReports(verificationArea, ele, img_name, str, desc);
|
|
83
77
|
} catch (reportError) {
|
|
84
78
|
console.error('Error generating report of element:', reportError);
|
|
85
79
|
}
|
|
@@ -94,19 +88,13 @@ class I18nVerify {
|
|
|
94
88
|
const eles = await this.#driver.getElements(xpaths);
|
|
95
89
|
if (eles.length > 0) {
|
|
96
90
|
for (const el of eles) {
|
|
97
|
-
if (await this.#driver.
|
|
91
|
+
if (await this.#driver.isElementDisplayed(el)) {
|
|
98
92
|
let uiStrings;
|
|
99
93
|
try {
|
|
100
94
|
uiStrings = await this.#driver.getElementStrings(el);
|
|
101
95
|
try {
|
|
102
96
|
for (const str of uiStrings) {
|
|
103
|
-
await this.#generateReports(
|
|
104
|
-
verificationArea,
|
|
105
|
-
el,
|
|
106
|
-
img_name,
|
|
107
|
-
str,
|
|
108
|
-
desc
|
|
109
|
-
});
|
|
97
|
+
await this.#generateReports(verificationArea, el, img_name, str, desc);
|
|
110
98
|
}
|
|
111
99
|
} catch (reportError) {
|
|
112
100
|
console.error('Error generating report of element:', reportError);
|
|
@@ -116,25 +104,11 @@ class I18nVerify {
|
|
|
116
104
|
}
|
|
117
105
|
}
|
|
118
106
|
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
await this.#driver.switchFrame(null);
|
|
122
|
-
const iframes = await this.#driver.getElements('//iframe');
|
|
123
|
-
await this.#verifyIframeElements({
|
|
124
|
-
iframes,
|
|
125
|
-
img_name,
|
|
126
|
-
desc
|
|
127
|
-
});
|
|
107
|
+
} else {
|
|
108
|
+
console.error('No elements found:', xpaths);
|
|
128
109
|
}
|
|
129
110
|
}
|
|
130
|
-
async #generateReports({
|
|
131
|
-
verificationArea,
|
|
132
|
-
el,
|
|
133
|
-
img_name,
|
|
134
|
-
str,
|
|
135
|
-
desc,
|
|
136
|
-
iframePresent = false
|
|
137
|
-
}) {
|
|
111
|
+
async #generateReports(verificationArea, el, image_name, str, desc) {
|
|
138
112
|
//TODO: in some cases, the str is having 0
|
|
139
113
|
//needs more inspection
|
|
140
114
|
if (typeof str !== 'string' || !str || Number(str) === 0) {
|
|
@@ -142,60 +116,45 @@ class I18nVerify {
|
|
|
142
116
|
}
|
|
143
117
|
_reports.default.incrementCount(_constants.I18N_STATUS.REVIEWED);
|
|
144
118
|
const i18nStatus = _index.default.getIssueType(str),
|
|
145
|
-
src_img = (0, _file.joinPaths)(_reports.default.reviewedReports(str,
|
|
119
|
+
src_img = (0, _file.joinPaths)(_reports.default.reviewedReports(str, image_name), image_name);
|
|
146
120
|
if (i18nStatus && src_img && typeof _reports.default[i18nStatus] === 'function') {
|
|
147
121
|
const color = this.#defineColor(i18nStatus, str),
|
|
148
|
-
dest_img = (0, _file.joinPaths)(_reports.default[i18nStatus](str,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
el
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
122
|
+
dest_img = (0, _file.joinPaths)(_reports.default[i18nStatus](str, image_name), image_name);
|
|
123
|
+
const eles = [];
|
|
124
|
+
eles.push(el);
|
|
125
|
+
browser.perform(async function () {
|
|
126
|
+
for (const el of eles) {
|
|
127
|
+
if (true) {
|
|
128
|
+
// Highlight the element using custom JavaScript
|
|
129
|
+
browser.execute(function (el, color) {
|
|
130
|
+
el.style.border = `3px solid ${color}`;
|
|
131
|
+
setTimeout(function () {
|
|
132
|
+
el.style.border = 'none'; // Remove border
|
|
133
|
+
}, 50);
|
|
134
|
+
}, [el, color]);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
159
137
|
});
|
|
138
|
+
await this.#highlightReports(verificationArea, el, color, src_img, dest_img, str);
|
|
160
139
|
}
|
|
161
140
|
}
|
|
162
|
-
async #highlightReports({
|
|
163
|
-
verificationArea,
|
|
164
|
-
el,
|
|
165
|
-
color,
|
|
166
|
-
src_img,
|
|
167
|
-
dest_img,
|
|
168
|
-
str,
|
|
169
|
-
iframePresent,
|
|
170
|
-
desc
|
|
171
|
-
}) {
|
|
141
|
+
async #highlightReports(verificationArea, el, color, src_img, rep_img, str) {
|
|
172
142
|
try {
|
|
173
|
-
if (_fs.default.existsSync(src_img) && !_fs.default.existsSync(
|
|
174
|
-
_fs.default.copyFileSync(src_img,
|
|
175
|
-
} else if (!_fs.default.existsSync(
|
|
143
|
+
if (_fs.default.existsSync(src_img) && !_fs.default.existsSync(rep_img)) {
|
|
144
|
+
_fs.default.copyFileSync(src_img, rep_img);
|
|
145
|
+
} else if (!_fs.default.existsSync(rep_img) && !_fs.default.existsSync(src_img)) {
|
|
176
146
|
await this.#captureCurrentScreen(src_img);
|
|
177
|
-
_fs.default.copyFileSync(src_img,
|
|
147
|
+
_fs.default.copyFileSync(src_img, rep_img);
|
|
178
148
|
}
|
|
179
149
|
} catch (error) {
|
|
180
150
|
_logs.default.error(`zee-error#2 - ${src_img} is not exists and unable to capture screenshot`);
|
|
181
151
|
}
|
|
182
|
-
|
|
183
|
-
let eleRec = await this.#getRect(el);
|
|
152
|
+
const area = await this.#driver.getElement(verificationArea);
|
|
184
153
|
const areaColor = _constants.COLOR.GRB_BLUE;
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
if (key in eleRec && key in areaRec) {
|
|
190
|
-
eleRec[key] = areaRec[key] + eleRec[key];
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
} else {
|
|
194
|
-
const area = await this.#driver.getElement(verificationArea);
|
|
195
|
-
areaRec = await this.#getRect(area);
|
|
196
|
-
}
|
|
197
|
-
await _dGraphic.default.drawRectangle(areaRec, areaColor, dest_img);
|
|
198
|
-
await _dGraphic.default.drawRectangle(eleRec, color, dest_img);
|
|
154
|
+
const areaRec = await this.#getRect(area);
|
|
155
|
+
const eleRec = await this.#getRect(el);
|
|
156
|
+
await _graphic.default.drawRectangle(areaRec, areaColor, rep_img);
|
|
157
|
+
await _graphic.default.drawRectangle(eleRec, color, rep_img);
|
|
199
158
|
}
|
|
200
159
|
async #captureCurrentScreen(imagePath) {
|
|
201
160
|
await this.#driver.captureScreenshot(imagePath);
|
|
@@ -214,42 +173,5 @@ class I18nVerify {
|
|
|
214
173
|
_logs.default.debug(`[${str}] ${_constants.STATUS_COLOR[i18nStatus][1]} ${_constants.STATUS_INFO[i18nStatus]}${'\x1b[0m'}`);
|
|
215
174
|
return _constants.STATUS_COLOR[i18nStatus][0];
|
|
216
175
|
}
|
|
217
|
-
async #verifyIframeElements({
|
|
218
|
-
iframes,
|
|
219
|
-
img_name,
|
|
220
|
-
desc
|
|
221
|
-
}) {
|
|
222
|
-
for (const iframe of iframes) {
|
|
223
|
-
const frameID = await this.#driver.getElementID(iframe);
|
|
224
|
-
const verificationArea = await this.#getRect(iframe);
|
|
225
|
-
await this.#driver.switchFrame(frameID);
|
|
226
|
-
this.#driver.pause(10);
|
|
227
|
-
const iframeBody = await this.#driver.getElement('//body');
|
|
228
|
-
await this.#driver.isElementPresent(iframeBody);
|
|
229
|
-
const iframeElements = await this.#driver.getElements('//*[normalize-space(text())]');
|
|
230
|
-
if (iframeElements.length > 0) {
|
|
231
|
-
for (const el of iframeElements) {
|
|
232
|
-
if (await this.#driver.isElementPresent(el)) {
|
|
233
|
-
let uiStrings = await this.#driver.getElementStrings(el);
|
|
234
|
-
try {
|
|
235
|
-
for (const str of uiStrings) {
|
|
236
|
-
await this.#generateReports({
|
|
237
|
-
verificationArea,
|
|
238
|
-
el,
|
|
239
|
-
img_name,
|
|
240
|
-
str,
|
|
241
|
-
desc,
|
|
242
|
-
iframePresent: true
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
} catch (reportError) {
|
|
246
|
-
console.error('Error generating report of iframe elements:', reportError);
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
await this.#driver.switchFrame(null);
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
176
|
}
|
|
255
177
|
exports.default = I18nVerify;
|
|
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
var _jimp = _interopRequireDefault(require("jimp"));
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
var _fs = _interopRequireDefault(require("fs"));
|
|
10
|
-
var _logs = _interopRequireDefault(require("
|
|
10
|
+
var _logs = _interopRequireDefault(require("./logs.js"));
|
|
11
11
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
12
|
class Graphic {
|
|
13
13
|
/**
|