@checksum-ai/runtime 1.1.18 → 1.1.22
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/checksum-root/.gitignore.example +1 -0
- package/checksum-root/checksum.config.ts +2 -0
- package/checksumlib.js +59 -35
- package/cli.js +30 -30
- package/index.d.ts +79 -20
- package/index.js +63 -63
- package/package.json +2 -1
package/checksumlib.js
CHANGED
|
@@ -22885,6 +22885,14 @@
|
|
|
22885
22885
|
return str.substring(0, firstParantheses + 1) + "`" + str.substring(firstParantheses + 2, str.length - 2) + "`)";
|
|
22886
22886
|
}
|
|
22887
22887
|
__name(replaceLocatorQuotesWithTicks, "replaceLocatorQuotesWithTicks");
|
|
22888
|
+
function getElementWindowPlaywright(node) {
|
|
22889
|
+
const elementWindow = node.ownerDocument.defaultView;
|
|
22890
|
+
if (elementWindow !== window && !elementWindow.playwright) {
|
|
22891
|
+
elementWindow.playwright = window.playwright;
|
|
22892
|
+
}
|
|
22893
|
+
return elementWindow.playwright;
|
|
22894
|
+
}
|
|
22895
|
+
__name(getElementWindowPlaywright, "getElementWindowPlaywright");
|
|
22888
22896
|
var COVERED_ATTRIBUTES = [
|
|
22889
22897
|
"role",
|
|
22890
22898
|
"aria-label",
|
|
@@ -22903,7 +22911,8 @@
|
|
|
22903
22911
|
"style",
|
|
22904
22912
|
"href",
|
|
22905
22913
|
"src",
|
|
22906
|
-
"path"
|
|
22914
|
+
"path",
|
|
22915
|
+
"type"
|
|
22907
22916
|
];
|
|
22908
22917
|
|
|
22909
22918
|
// ../../node_modules/css-selector-generator/esm/utilities-iselement.js
|
|
@@ -23592,6 +23601,7 @@
|
|
|
23592
23601
|
}, "guardReturn");
|
|
23593
23602
|
|
|
23594
23603
|
// src/lib/test-generator/selectors/pw-custom-locator-generator.ts
|
|
23604
|
+
var DEBUG_MODE = false;
|
|
23595
23605
|
var PlaywrightCustomLocatorGenerator = class _PlaywrightCustomLocatorGenerator {
|
|
23596
23606
|
constructor(rootNode = document) {
|
|
23597
23607
|
this.rootNode = rootNode;
|
|
@@ -23871,7 +23881,9 @@
|
|
|
23871
23881
|
});
|
|
23872
23882
|
element = element.parentElement;
|
|
23873
23883
|
}
|
|
23874
|
-
|
|
23884
|
+
if (added.length) {
|
|
23885
|
+
console.log("Added CSS key features", added);
|
|
23886
|
+
}
|
|
23875
23887
|
} catch (error) {
|
|
23876
23888
|
console.error("Error extracting CSS key features", error);
|
|
23877
23889
|
}
|
|
@@ -23995,13 +24007,6 @@
|
|
|
23995
24007
|
console.error("[filterListItemsSelectors] error", error.message);
|
|
23996
24008
|
}
|
|
23997
24009
|
}
|
|
23998
|
-
getElementWindowPlaywright(node) {
|
|
23999
|
-
const elementWindow = node.ownerDocument.defaultView;
|
|
24000
|
-
if (elementWindow !== window && !elementWindow.playwright) {
|
|
24001
|
-
elementWindow.playwright = window.playwright;
|
|
24002
|
-
}
|
|
24003
|
-
return elementWindow.playwright;
|
|
24004
|
-
}
|
|
24005
24010
|
/**
|
|
24006
24011
|
* Returns the relevant locator for testing the element
|
|
24007
24012
|
* If we are generating a relative selector - returns playwright entry point
|
|
@@ -24010,7 +24015,7 @@
|
|
|
24010
24015
|
* @returns Locator or playwright entry point
|
|
24011
24016
|
*/
|
|
24012
24017
|
getLocatorBase(element) {
|
|
24013
|
-
const playwright =
|
|
24018
|
+
const playwright = getElementWindowPlaywright(element);
|
|
24014
24019
|
if (this.rootNode === document) {
|
|
24015
24020
|
return playwright;
|
|
24016
24021
|
}
|
|
@@ -24020,9 +24025,10 @@
|
|
|
24020
24025
|
* Returns locator representation of a selector
|
|
24021
24026
|
*/
|
|
24022
24027
|
getSelectorLocator(selector, element) {
|
|
24023
|
-
return this.
|
|
24024
|
-
|
|
24025
|
-
|
|
24028
|
+
return getElementWindowPlaywright(element ?? this.targetElement).asLocator(
|
|
24029
|
+
"javascript",
|
|
24030
|
+
selector
|
|
24031
|
+
);
|
|
24026
24032
|
}
|
|
24027
24033
|
/**
|
|
24028
24034
|
* This method tries to reduce the number of elements returned by the selectors that return multiple elements
|
|
@@ -24175,16 +24181,31 @@
|
|
|
24175
24181
|
)
|
|
24176
24182
|
]);
|
|
24177
24183
|
}
|
|
24178
|
-
|
|
24179
|
-
|
|
24180
|
-
|
|
24181
|
-
|
|
24182
|
-
|
|
24184
|
+
const getAccessibleName = /* @__PURE__ */ __name(() => {
|
|
24185
|
+
const normalize = /* @__PURE__ */ __name((txt) => this.limitTextLength(this.normalize(txt), options.exact), "normalize");
|
|
24186
|
+
const none = { text: "", exact: false };
|
|
24187
|
+
const attributeVal = element.getAttribute("aria-label") ?? element.getAttribute("aria-labelledby") ?? element.getAttribute("title");
|
|
24188
|
+
if (attributeVal) {
|
|
24189
|
+
return normalize(attributeVal);
|
|
24190
|
+
}
|
|
24191
|
+
const text = normalizeWhiteSpace(elementText(element).full);
|
|
24192
|
+
if (!text?.length) {
|
|
24193
|
+
return none;
|
|
24194
|
+
}
|
|
24195
|
+
const textVal = normalize(text);
|
|
24196
|
+
if (this.usedFilters.hasText.includes(textVal.text)) {
|
|
24197
|
+
return none;
|
|
24198
|
+
}
|
|
24199
|
+
this.usedFilters.hasText.push(textVal.text);
|
|
24200
|
+
return textVal;
|
|
24201
|
+
}, "getAccessibleName");
|
|
24202
|
+
const { text: name, exact } = getAccessibleName();
|
|
24183
24203
|
if (name && name.length > 0 && name.length < 30) {
|
|
24184
24204
|
props.push(["name", escapeForAttributeSelector(name, exact)]);
|
|
24185
24205
|
}
|
|
24186
24206
|
return options.returnLocator ? `getByRole('${role}', { ${props.join(", ")} })` : `internal:role=${role}${props.map(([n2, v2]) => `[${n2}=${v2}]`).join("")}`;
|
|
24187
24207
|
} catch (error) {
|
|
24208
|
+
console.error("Error getting role locator", error);
|
|
24188
24209
|
}
|
|
24189
24210
|
}
|
|
24190
24211
|
getByTextLocator(element, options = {}) {
|
|
@@ -24197,10 +24218,7 @@
|
|
|
24197
24218
|
return;
|
|
24198
24219
|
}
|
|
24199
24220
|
if (Array.from(element.children).filter((el) => el instanceof HTMLElement).some(
|
|
24200
|
-
// (child) => (child as HTMLElement).innerText === textContent
|
|
24201
24221
|
(child) => normalizeWhiteSpace(elementText(child).full) === text
|
|
24202
|
-
// this.normalize((child as HTMLElement).textContent) === text
|
|
24203
|
-
// this.normalize((child as HTMLElement).textContent) === text
|
|
24204
24222
|
)) {
|
|
24205
24223
|
if (!this.usedFilters.hasText.includes(text)) {
|
|
24206
24224
|
this.usedFilters.hasText.push(text);
|
|
@@ -24305,7 +24323,9 @@
|
|
|
24305
24323
|
return { text, exact };
|
|
24306
24324
|
}
|
|
24307
24325
|
checkTimeout(throwError = true) {
|
|
24308
|
-
|
|
24326
|
+
if (DEBUG_MODE) {
|
|
24327
|
+
return false;
|
|
24328
|
+
}
|
|
24309
24329
|
if (this.MAX_PROCESSING_TIME && Date.now() - this.startTimestamp > this.MAX_PROCESSING_TIME) {
|
|
24310
24330
|
if (throwError) {
|
|
24311
24331
|
throw new TimeoutError();
|
|
@@ -24408,7 +24428,10 @@
|
|
|
24408
24428
|
).filter((s2) => s2 && s2.trim().length > 0),
|
|
24409
24429
|
playwrightSelectors: await new PlaywrightCustomLocatorGenerator(
|
|
24410
24430
|
commonRoot
|
|
24411
|
-
).generate(targetElement.element
|
|
24431
|
+
).generate(targetElement.element, [], {
|
|
24432
|
+
addCSSSelectorGenerator: false,
|
|
24433
|
+
expandCSSKeyElements: false
|
|
24434
|
+
}),
|
|
24412
24435
|
featuresMetadata: targetElement.featuresMetadata
|
|
24413
24436
|
},
|
|
24414
24437
|
contextElements
|
|
@@ -24430,13 +24453,14 @@
|
|
|
24430
24453
|
}
|
|
24431
24454
|
});
|
|
24432
24455
|
const commonParents = this.getSmallestCommonParents(elementGroups).map(this.calculateElementSize).sort((a2, b) => a2.size - b.size).map((e2) => e2.element);
|
|
24433
|
-
|
|
24434
|
-
|
|
24435
|
-
const { element } = locator.locator(targetSelector);
|
|
24436
|
-
if (element) {
|
|
24437
|
-
return window.playwright.selector(element);
|
|
24438
|
-
}
|
|
24456
|
+
if (!targetSelector) {
|
|
24457
|
+
return commonParents.map((cp) => getElementWindowPlaywright(cp).selector(cp)).filter((s2) => s2);
|
|
24439
24458
|
}
|
|
24459
|
+
return commonParents.map((cp) => {
|
|
24460
|
+
const playwright = getElementWindowPlaywright(cp);
|
|
24461
|
+
const { element } = playwright.locator(playwright.selector(cp)).locator(targetSelector);
|
|
24462
|
+
return element ? playwright.selector(element) : null;
|
|
24463
|
+
}).filter((e2) => e2);
|
|
24440
24464
|
}
|
|
24441
24465
|
/**
|
|
24442
24466
|
* Performs a compound selection from metadata
|
|
@@ -24465,10 +24489,10 @@
|
|
|
24465
24489
|
compoundSelector.targetSelection
|
|
24466
24490
|
);
|
|
24467
24491
|
if (histogram.size > 0) {
|
|
24468
|
-
const
|
|
24469
|
-
|
|
24492
|
+
const selectors = Array.from(histogram.keys()).slice(0, 20).map(
|
|
24493
|
+
(el) => getElementWindowPlaywright(el).generateSelectorAndLocator(el)
|
|
24470
24494
|
);
|
|
24471
|
-
return
|
|
24495
|
+
return selectors;
|
|
24472
24496
|
}
|
|
24473
24497
|
}
|
|
24474
24498
|
}
|
|
@@ -24492,7 +24516,7 @@
|
|
|
24492
24516
|
targetSelection.cssSelectors.forEach((selector) => {
|
|
24493
24517
|
try {
|
|
24494
24518
|
addElementstoHistogram(
|
|
24495
|
-
|
|
24519
|
+
querySelectorAllExtended(selector, commonParent)
|
|
24496
24520
|
);
|
|
24497
24521
|
} catch (error) {
|
|
24498
24522
|
}
|
|
@@ -24638,7 +24662,7 @@
|
|
|
24638
24662
|
(combination) => this.createContextualSelector(commonRoot, target, combination)
|
|
24639
24663
|
).filter((s2) => s2).filter((s2) => {
|
|
24640
24664
|
try {
|
|
24641
|
-
const result =
|
|
24665
|
+
const result = querySelectorAllExtended(s2, commonRoot);
|
|
24642
24666
|
return result.length === 1 && result[0] === target;
|
|
24643
24667
|
} catch (error) {
|
|
24644
24668
|
return false;
|
|
@@ -24771,7 +24795,7 @@
|
|
|
24771
24795
|
getSmallestCommonParentsFromMetadata(contextElements) {
|
|
24772
24796
|
const elementsBySelector = contextElements.map((ce) => {
|
|
24773
24797
|
try {
|
|
24774
|
-
const elements =
|
|
24798
|
+
const elements = querySelectorAllExtended(ce.selector);
|
|
24775
24799
|
return ce.selection.type === "content" ? elements.filter(
|
|
24776
24800
|
(element) => element.textContent === ce.selection.value
|
|
24777
24801
|
) : elements;
|