feat: get children selectors of each gen selector
This commit is contained in:
@@ -759,7 +759,6 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates
|
|||||||
|
|
||||||
while (element && element !== document.body && depth < maxDepth) {
|
while (element && element !== document.body && depth < maxDepth) {
|
||||||
const selector = getNonUniqueSelector(element);
|
const selector = getNonUniqueSelector(element);
|
||||||
|
|
||||||
path.unshift(selector);
|
path.unshift(selector);
|
||||||
element = element.parentElement;
|
element = element.parentElement;
|
||||||
depth++;
|
depth++;
|
||||||
@@ -768,12 +767,27 @@ export const getNonUniqueSelectors = async (page: Page, coordinates: Coordinates
|
|||||||
return path.join(' > ');
|
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;
|
const element = document.elementFromPoint(x, y) as HTMLElement | null;
|
||||||
if (!element) return null;
|
if (!element) return null;
|
||||||
|
|
||||||
const generalSelector = getSelectorPath(element);
|
const generalSelector = getSelectorPath(element);
|
||||||
|
const childSelectors = getChildSelectors(element);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
generalSelector,
|
generalSelector,
|
||||||
|
childSelectors,
|
||||||
};
|
};
|
||||||
}, coordinates);
|
}, 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
|
* Returns the first pair from the given workflow that contains the given selector
|
||||||
* inside the where condition, and it is the only selector there.
|
* inside the where condition, and it is the only selector there.
|
||||||
|
|||||||
Reference in New Issue
Block a user