Enhance element extraction by including hidden containers and shadow DOM elements in the DOM processing logic
This commit is contained in:
@@ -964,7 +964,31 @@ class TestExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Start from body and extract all relevant elements
|
// Start from body and extract all relevant elements
|
||||||
return processContainer(document.body);
|
// Also check the entire document for elements that might be in hidden containers
|
||||||
|
const bodyResults = processContainer(document.body);
|
||||||
|
|
||||||
|
// Additionally, search the entire document for our target elements
|
||||||
|
// This catches elements that might be in hidden containers or shadow DOM
|
||||||
|
const allElements = document.querySelectorAll(keepElements.join(','));
|
||||||
|
const additionalResults = [];
|
||||||
|
|
||||||
|
allElements.forEach(element => {
|
||||||
|
const processed = processElement(element);
|
||||||
|
if (processed) {
|
||||||
|
// Check if this element is already in bodyResults
|
||||||
|
const alreadyExists = bodyResults.some(existing =>
|
||||||
|
existing.tag === processed.tag &&
|
||||||
|
existing.attributes.id === processed.attributes.id &&
|
||||||
|
existing.attributes.class === processed.attributes.class
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!alreadyExists) {
|
||||||
|
additionalResults.push(processed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return [...bodyResults, ...additionalResults];
|
||||||
});
|
});
|
||||||
|
|
||||||
// Convert to readable HTML format
|
// Convert to readable HTML format
|
||||||
|
|||||||
Reference in New Issue
Block a user