feat: if path, sort, optimize path & input

This commit is contained in:
karishmas6
2024-06-05 10:45:51 +05:30
parent 1afd38f1c0
commit ee624361ff

View File

@@ -163,6 +163,17 @@ export const getSelectors = async (page: Page, coordinates: Coordinates) => {
bottomUpSearch(input, Limit.Two, () => bottomUpSearch(input, Limit.One))
);
if (path) {
const optimized = sort(optimize(path, input));
if (optimized.length > 0) {
path = optimized[0];
}
return selector(path);
} else {
throw new Error(`Selector was not found.`);
}
}
function findRootDocument(rootNode: Element | Document, defaults: Options) {