@empiricalrun/test-gen 0.38.7 → 0.38.8
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/CHANGELOG.md
CHANGED
|
@@ -24,6 +24,8 @@ function annotateClickableElements(options = {}) {
|
|
|
24
24
|
// Check if the element is not blocked and visible for clicking
|
|
25
25
|
function isElementClickNotBlocked(element, windowToAnnotate) {
|
|
26
26
|
const rect = element.getBoundingClientRect();
|
|
27
|
+
const originalScrollX = windowToAnnotate.scrollX;
|
|
28
|
+
const originalScrollY = windowToAnnotate.scrollY;
|
|
27
29
|
|
|
28
30
|
// Calculate the center point of the element
|
|
29
31
|
const centerX = rect.left + rect.width / 2;
|
|
@@ -56,7 +58,12 @@ function annotateClickableElements(options = {}) {
|
|
|
56
58
|
const newCenterX = newRect.left + newRect.width / 2;
|
|
57
59
|
const newCenterY = newRect.top + newRect.height / 2;
|
|
58
60
|
const topElement = document.elementFromPoint(newCenterX, newCenterY);
|
|
59
|
-
|
|
61
|
+
const doesElementContainTopElement = element.contains(topElement);
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
// Restore the original scroll positions
|
|
65
|
+
windowToAnnotate.scrollTo(originalScrollX, originalScrollY);
|
|
66
|
+
return doesElementContainTopElement;
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
const topElement = windowToAnnotate.document.elementFromPoint(centerX, centerY);
|
|
@@ -369,7 +376,9 @@ function annotateClickableElements(options = {}) {
|
|
|
369
376
|
|
|
370
377
|
// Filter for clickable elements
|
|
371
378
|
const clickableElements = Array.from(windowToAnnotate.document.querySelectorAll("*")).filter((el) => {
|
|
372
|
-
|
|
379
|
+
const isClickable = isElementClickable(el);
|
|
380
|
+
const isClickNotBlocked = isElementClickNotBlocked(el, windowToAnnotate);
|
|
381
|
+
return isClickable && isClickNotBlocked;
|
|
373
382
|
});
|
|
374
383
|
// Generate hint strings for the clickable elements
|
|
375
384
|
const hints = generateHintStrings(hintCharacterSet, Math.min(maxHints, clickableElements.length));
|
|
@@ -24,6 +24,8 @@ function annotateClickableElements(options = {}) {
|
|
|
24
24
|
// Check if the element is not blocked and visible for clicking
|
|
25
25
|
function isElementClickNotBlocked(element, windowToAnnotate) {
|
|
26
26
|
const rect = element.getBoundingClientRect();
|
|
27
|
+
const originalScrollX = windowToAnnotate.scrollX;
|
|
28
|
+
const originalScrollY = windowToAnnotate.scrollY;
|
|
27
29
|
|
|
28
30
|
// Calculate the center point of the element
|
|
29
31
|
const centerX = rect.left + rect.width / 2;
|
|
@@ -56,7 +58,12 @@ function annotateClickableElements(options = {}) {
|
|
|
56
58
|
const newCenterX = newRect.left + newRect.width / 2;
|
|
57
59
|
const newCenterY = newRect.top + newRect.height / 2;
|
|
58
60
|
const topElement = document.elementFromPoint(newCenterX, newCenterY);
|
|
59
|
-
|
|
61
|
+
const doesElementContainTopElement = element.contains(topElement);
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
// Restore the original scroll positions
|
|
65
|
+
windowToAnnotate.scrollTo(originalScrollX, originalScrollY);
|
|
66
|
+
return doesElementContainTopElement;
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
const topElement = windowToAnnotate.document.elementFromPoint(centerX, centerY);
|
|
@@ -369,7 +376,9 @@ function annotateClickableElements(options = {}) {
|
|
|
369
376
|
|
|
370
377
|
// Filter for clickable elements
|
|
371
378
|
const clickableElements = Array.from(windowToAnnotate.document.querySelectorAll("*")).filter((el) => {
|
|
372
|
-
|
|
379
|
+
const isClickable = isElementClickable(el);
|
|
380
|
+
const isClickNotBlocked = isElementClickNotBlocked(el, windowToAnnotate);
|
|
381
|
+
return isClickable && isClickNotBlocked;
|
|
373
382
|
});
|
|
374
383
|
// Generate hint strings for the clickable elements
|
|
375
384
|
const hints = generateHintStrings(hintCharacterSet, Math.min(maxHints, clickableElements.length));
|