From a5f8f9d64e3d92826b4fe8fb82e45b9624a7e577 Mon Sep 17 00:00:00 2001 From: Rohit Date: Thu, 20 Mar 2025 01:40:51 +0530 Subject: [PATCH] feat: rm threshold logic --- server/src/workflow-management/selector.ts | 102 --------------------- 1 file changed, 102 deletions(-) diff --git a/server/src/workflow-management/selector.ts b/server/src/workflow-management/selector.ts index 34c37759..20b56713 100644 --- a/server/src/workflow-management/selector.ts +++ b/server/src/workflow-management/selector.ts @@ -474,40 +474,6 @@ export const getElementInformation = async ( element = tableParent; } } - - if (element.tagName !== 'TABLE') { - while (element.parentElement) { - if (element.tagName.toLowerCase() === 'body' || - element.tagName.toLowerCase() === 'html') { - break; - } - - const parentRect = element.parentElement.getBoundingClientRect(); - const childRect = element.getBoundingClientRect(); - - const fullyContained = - parentRect.left <= childRect.left && - parentRect.right >= childRect.right && - parentRect.top <= childRect.top && - parentRect.bottom >= childRect.bottom; - - const significantOverlap = - (childRect.width * childRect.height) / - (parentRect.width * parentRect.height) > 0.1; - - if (fullyContained && significantOverlap) { - const nextParent = element.parentElement; - if (nextParent.tagName.toLowerCase() !== 'body' && - nextParent.tagName.toLowerCase() !== 'html') { - element = nextParent; - } else { - break; - } - } else { - break; - } - } - } const ownerDocument = element.ownerDocument; const frameElement = ownerDocument?.defaultView?.frameElement; @@ -1027,40 +993,6 @@ export const getRect = async (page: Page, coordinates: Coordinates, listSelector } } - if (element.tagName !== 'TABLE') { - while (element.parentElement) { - if (element.tagName.toLowerCase() === 'body' || - element.tagName.toLowerCase() === 'html') { - break; - } - - const parentRect = element.parentElement.getBoundingClientRect(); - const childRect = element.getBoundingClientRect(); - - const fullyContained = - parentRect.left <= childRect.left && - parentRect.right >= childRect.right && - parentRect.top <= childRect.top && - parentRect.bottom >= childRect.bottom; - - const significantOverlap = - (childRect.width * childRect.height) / - (parentRect.width * parentRect.height) > 0.1; - - if (fullyContained && significantOverlap) { - const nextParent = element.parentElement; - if (nextParent.tagName.toLowerCase() !== 'body' && - nextParent.tagName.toLowerCase() !== 'html') { - element = nextParent; - } else { - break; - } - } else { - break; - } - } - } - const rectangle = element?.getBoundingClientRect(); if (rectangle) { const createRectObject = (rect: DOMRect) => ({ @@ -2377,40 +2309,6 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates } } - if (element.tagName !== 'TABLE') { - while (element.parentElement) { - if (element.tagName.toLowerCase() === 'body' || - element.tagName.toLowerCase() === 'html') { - break; - } - - const parentRect = element.parentElement.getBoundingClientRect(); - const childRect = element.getBoundingClientRect(); - - const fullyContained = - parentRect.left <= childRect.left && - parentRect.right >= childRect.right && - parentRect.top <= childRect.top && - parentRect.bottom >= childRect.bottom; - - const significantOverlap = - (childRect.width * childRect.height) / - (parentRect.width * parentRect.height) > 0.1; - - if (fullyContained && significantOverlap) { - const nextParent = element.parentElement; - if (nextParent.tagName.toLowerCase() !== 'body' && - nextParent.tagName.toLowerCase() !== 'html') { - element = nextParent; - } else { - break; - } - } else { - break; - } - } - } - const generalSelector = getSelectorPath(element); return { generalSelector }; }, coordinates);