@dev-blinq/cucumber_client 1.0.1425-dev → 1.0.1426-dev
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.
|
@@ -150,6 +150,7 @@ class LocatorGenerator {
|
|
|
150
150
|
}
|
|
151
151
|
getTextLocators(element, options) {
|
|
152
152
|
const injectedScript = this.injectedScript;
|
|
153
|
+
const { textToIgnore = null } = options;
|
|
153
154
|
const selectorPartLists = this.PW.selectorGenerator.buildTextCandidates(injectedScript, element, options);
|
|
154
155
|
const result = [];
|
|
155
156
|
for (const selectorPartList of selectorPartLists) {
|
|
@@ -157,6 +158,10 @@ class LocatorGenerator {
|
|
|
157
158
|
const tSelectorList = [];
|
|
158
159
|
for (const selectorPart of selectorPartList) {
|
|
159
160
|
const { engine, selector } = selectorPart;
|
|
161
|
+
if (textToIgnore && selector.includes(textToIgnore)
|
|
162
|
+
) {
|
|
163
|
+
continue;
|
|
164
|
+
}
|
|
160
165
|
if (engine === "css") {
|
|
161
166
|
tSelectorList.push(selector);
|
|
162
167
|
} else {
|
|
@@ -439,6 +444,10 @@ class LocatorGenerator {
|
|
|
439
444
|
const nonUnique = [];
|
|
440
445
|
try {
|
|
441
446
|
for (const locator of locators) {
|
|
447
|
+
if (!locator || !locator.css || typeof locator.css !== "string") {
|
|
448
|
+
console.error("Locator must have a valid css selector found: ", locator);
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
442
451
|
const elements = this.getMatchingElements(locator.css, options);
|
|
443
452
|
if (elements.length === 0) {
|
|
444
453
|
console.warn(`No elements found for locator: ${locator.css}`);
|
|
@@ -673,9 +682,11 @@ class LocatorGenerator {
|
|
|
673
682
|
const allAncestors = this.dom_Parent.getFullAncestorChainToRoot(element, root);
|
|
674
683
|
allAncestors.shift(); // remove the element itself from the ancestors
|
|
675
684
|
|
|
685
|
+
const cache = new Map();
|
|
686
|
+
const textToIgnore = this.PW.selectorUtils.elementText(cache, element).full.trim();
|
|
676
687
|
const ancestorLocators = [];
|
|
677
688
|
for (const ancestor of allAncestors) {
|
|
678
|
-
const _locators = locatorGenerator(ancestor, options);
|
|
689
|
+
const _locators = locatorGenerator(ancestor, { ...options, textToIgnore });
|
|
679
690
|
if (!_locators || !Array.isArray(_locators) || _locators.length === 0) {
|
|
680
691
|
continue;
|
|
681
692
|
}
|