From fe99fb8e5fc08628d061e8778cbe63385a3fa01e Mon Sep 17 00:00:00 2001 From: seb Date: Thu, 17 Jul 2025 06:02:09 +0200 Subject: [PATCH] Enhance element extraction by including hidden containers and shadow DOM elements in the DOM processing logic --- src/executor.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/executor.js b/src/executor.js index 7c90405..71cae12 100644 --- a/src/executor.js +++ b/src/executor.js @@ -964,7 +964,31 @@ class TestExecutor { } // 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