From 88b7a7bf166587c3674c8d7b5ded861939ca711f Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 2 Sep 2024 10:31:27 +0530 Subject: [PATCH] chore: lint --- server/src/workflow-management/selector.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/server/src/workflow-management/selector.ts b/server/src/workflow-management/selector.ts index 00a19f40..96e1737d 100644 --- a/server/src/workflow-management/selector.ts +++ b/server/src/workflow-management/selector.ts @@ -754,11 +754,23 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates function getSelectorPath(element: HTMLElement | null): string { const path: string[] = []; - while (element && element !== document.body) { + let depth = 0; + const maxDepth = 2; // Limiting the depth of the selector path + + while (element && element !== document.body && depth < maxDepth) { const selector = getNonUniqueSelector(element); + + // Stop adding selectors when we reach certain container elements + if (selector.includes('quotes') || selector.includes('container')) { + path.unshift(selector); + break; + } + path.unshift(selector); element = element.parentElement; + depth++; } + return path.join(' > '); } @@ -781,6 +793,7 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates + /** * Returns the first pair from the given workflow that contains the given selector * inside the where condition, and it is the only selector there.