diff --git a/server/src/workflow-management/selector.ts b/server/src/workflow-management/selector.ts index 1941e49d..8f5d2cf8 100644 --- a/server/src/workflow-management/selector.ts +++ b/server/src/workflow-management/selector.ts @@ -759,7 +759,6 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates while (element && element !== document.body && depth < maxDepth) { const selector = getNonUniqueSelector(element); - path.unshift(selector); element = element.parentElement; depth++; @@ -768,12 +767,27 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates return path.join(' > '); } + function getChildSelectors(parent: HTMLElement): string[] { + const childSelectors: string[] = []; + const children = parent.querySelectorAll('*'); + + children.forEach(child => { + const childSelector = getSelectorPath(child as HTMLElement); + childSelectors.push(childSelector); + }); + + return childSelectors; + } + const element = document.elementFromPoint(x, y) as HTMLElement | null; if (!element) return null; const generalSelector = getSelectorPath(element); + const childSelectors = getChildSelectors(element); + return { generalSelector, + childSelectors, }; }, coordinates); @@ -785,6 +799,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.