@dev-blinq/cucumber_client 1.0.1326-stage → 1.0.1327-stage
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.
|
@@ -487,12 +487,16 @@ class LocatorGenerator {
|
|
|
487
487
|
categorizeLocators(element, locators, options) {
|
|
488
488
|
const unique = [];
|
|
489
489
|
const nonUnique = [];
|
|
490
|
+
const visible = options?.visible ?? true;
|
|
490
491
|
try {
|
|
491
492
|
for (const locator of locators) {
|
|
492
493
|
if (!locator || !locator.css || typeof locator.css !== "string") {
|
|
493
494
|
console.error("Locator must have a valid css selector found: ", locator);
|
|
494
495
|
continue;
|
|
495
496
|
}
|
|
497
|
+
if (visible === false) {
|
|
498
|
+
locator.visible = false;
|
|
499
|
+
}
|
|
496
500
|
const elements = this.getMatchingElements(locator.css, options);
|
|
497
501
|
if (elements.length === 0) {
|
|
498
502
|
console.warn(`No elements found for locator: ${locator.css}`);
|
|
@@ -813,7 +817,20 @@ class LocatorGenerator {
|
|
|
813
817
|
return [];
|
|
814
818
|
}
|
|
815
819
|
}
|
|
820
|
+
isElementVisible(element) {
|
|
821
|
+
if (!(element instanceof Element)) return false;
|
|
822
|
+
const style = window.getComputedStyle(element);
|
|
823
|
+
if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0") return false;
|
|
824
|
+
const rect = element.getBoundingClientRect();
|
|
825
|
+
if (rect.width === 0 || rect.height === 0) return false;
|
|
826
|
+
return true;
|
|
827
|
+
}
|
|
816
828
|
getElementLocators(element, options = {}) {
|
|
829
|
+
const isVisible = this.isElementVisible(element);
|
|
830
|
+
if (isVisible === false) {
|
|
831
|
+
console.warn("Element is not visible: ", element);
|
|
832
|
+
options.visible = isVisible;
|
|
833
|
+
}
|
|
817
834
|
try {
|
|
818
835
|
const {
|
|
819
836
|
excludeText = false,
|