ff-dom 1.0.3 → 1.0.4
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.
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getElementsFromHTML = void 0;
|
|
4
4
|
const jsdom_1 = require("jsdom");
|
|
5
|
-
const { stringify } = require("flatted");
|
|
6
5
|
const isUnique = (xpathResult) => {
|
|
7
6
|
return xpathResult && xpathResult.snapshotLength === 1;
|
|
8
7
|
};
|
|
@@ -67,6 +66,16 @@ const getXpathByName = (element) => {
|
|
|
67
66
|
}
|
|
68
67
|
return null;
|
|
69
68
|
};
|
|
69
|
+
const getName = (element) => {
|
|
70
|
+
const elementEl = element;
|
|
71
|
+
if (elementEl.hasAttribute("name")) {
|
|
72
|
+
const attrValue = elementEl.getAttribute("name");
|
|
73
|
+
const name = `${attrValue}`;
|
|
74
|
+
console.log("get name", name);
|
|
75
|
+
return name || null;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
};
|
|
70
79
|
const getXpathByPlaceholder = (element) => {
|
|
71
80
|
const selector = element.nodeName.toLowerCase();
|
|
72
81
|
const elementEl = element;
|
|
@@ -262,7 +271,6 @@ const getElementsFromHTML = (name, desc, type, locators, isShared, projectId, pr
|
|
|
262
271
|
{ name: "xpath", value: getXpathByName },
|
|
263
272
|
{ name: "xpath", value: getXpathByPlaceholder },
|
|
264
273
|
{ name: "xpath", value: getXpathByType },
|
|
265
|
-
{ name: "xpath", value: getVisibleText },
|
|
266
274
|
];
|
|
267
275
|
if (targetElement) {
|
|
268
276
|
const idValue = getId(targetElement);
|
|
@@ -276,6 +284,29 @@ const getElementsFromHTML = (name, desc, type, locators, isShared, projectId, pr
|
|
|
276
284
|
isRecorded: locator.isRecorded,
|
|
277
285
|
});
|
|
278
286
|
}
|
|
287
|
+
if (getVisibleText(targetElement)) {
|
|
288
|
+
const textValue = getVisibleText(targetElement);
|
|
289
|
+
finalLocators.push({
|
|
290
|
+
name: "linkText",
|
|
291
|
+
type: "static",
|
|
292
|
+
value: textValue,
|
|
293
|
+
reference: locator.reference,
|
|
294
|
+
status: locator.status,
|
|
295
|
+
isRecorded: locator.isRecorded,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
if (getName(targetElement)) {
|
|
299
|
+
console.log("inside name if");
|
|
300
|
+
const nameLocator = getName(targetElement);
|
|
301
|
+
finalLocators.push({
|
|
302
|
+
name: "name",
|
|
303
|
+
type: "static",
|
|
304
|
+
value: nameLocator,
|
|
305
|
+
reference: locator.reference,
|
|
306
|
+
status: locator.status,
|
|
307
|
+
isRecorded: locator.isRecorded,
|
|
308
|
+
});
|
|
309
|
+
}
|
|
279
310
|
const classValue = getClassName(targetElement);
|
|
280
311
|
if (classValue &&
|
|
281
312
|
classValue.trim() !== "" &&
|
package/package.json
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { JSDOM } from "jsdom";
|
|
2
|
-
const { stringify } = require("flatted");
|
|
3
2
|
|
|
4
3
|
type ElementDetails = {
|
|
5
4
|
id?: string | null;
|
|
@@ -104,6 +103,19 @@ const getXpathByName = (element: Element): string | null => {
|
|
|
104
103
|
return null;
|
|
105
104
|
};
|
|
106
105
|
|
|
106
|
+
const getName = (element: Element): string | null => {
|
|
107
|
+
const elementEl = element as HTMLElement;
|
|
108
|
+
|
|
109
|
+
if (elementEl.hasAttribute("name")) {
|
|
110
|
+
const attrValue = elementEl.getAttribute("name");
|
|
111
|
+
const name = `${attrValue}`;
|
|
112
|
+
console.log("get name", name);
|
|
113
|
+
return name || null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return null;
|
|
117
|
+
};
|
|
118
|
+
|
|
107
119
|
const getXpathByPlaceholder = (element: Element): string | null => {
|
|
108
120
|
const selector = element.nodeName.toLowerCase();
|
|
109
121
|
const elementEl = element as HTMLElement;
|
|
@@ -384,7 +396,6 @@ const getElementsFromHTML = (
|
|
|
384
396
|
{ name: "xpath", value: getXpathByName },
|
|
385
397
|
{ name: "xpath", value: getXpathByPlaceholder },
|
|
386
398
|
{ name: "xpath", value: getXpathByType },
|
|
387
|
-
{ name: "xpath", value: getVisibleText },
|
|
388
399
|
];
|
|
389
400
|
|
|
390
401
|
if (targetElement) {
|
|
@@ -399,6 +410,30 @@ const getElementsFromHTML = (
|
|
|
399
410
|
isRecorded: locator.isRecorded,
|
|
400
411
|
});
|
|
401
412
|
}
|
|
413
|
+
if (getVisibleText(targetElement)) {
|
|
414
|
+
const textValue = getVisibleText(targetElement);
|
|
415
|
+
finalLocators.push({
|
|
416
|
+
name: "linkText",
|
|
417
|
+
type: "static",
|
|
418
|
+
value: textValue,
|
|
419
|
+
reference: locator.reference,
|
|
420
|
+
status: locator.status,
|
|
421
|
+
isRecorded: locator.isRecorded,
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
if (getName(targetElement)) {
|
|
426
|
+
console.log("inside name if");
|
|
427
|
+
const nameLocator = getName(targetElement);
|
|
428
|
+
finalLocators.push({
|
|
429
|
+
name: "name",
|
|
430
|
+
type: "static",
|
|
431
|
+
value: nameLocator,
|
|
432
|
+
reference: locator.reference,
|
|
433
|
+
status: locator.status,
|
|
434
|
+
isRecorded: locator.isRecorded,
|
|
435
|
+
});
|
|
436
|
+
}
|
|
402
437
|
|
|
403
438
|
const classValue = getClassName(targetElement);
|
|
404
439
|
if (
|