Hello @Allan_Zimmermann,
I’m currently working on a web automation project where I need to extract data from a portal. The element I want to interact with is inside the Shadow DOM, which makes capturing the selectors challenging. Therefore, I’m using JavaScript to extract the required data.
Here’s the JavaScript code I’m using:
(() => {
// Declare the sShowDetails variable
let sShowDetails = null;
try {
// Locate the shadow host
const shadowHost = document.querySelector("#main-wrapper > div.page-wrapper > div > div > mymsc-instantquote-app");
if (shadowHost) {
const shadowRoot = shadowHost.shadowRoot;
if (shadowRoot) {
// Locate the element inside the shadow DOM to retrieve the data from
const dataElement = shadowRoot.querySelector("#root > div.breakdown-modal.f-Archivo.MuiModal-root.css-8ndowl > div.breakdown-modal-container");
if (dataElement) {
// Extract the text or inner HTML of the element
const data = dataElement.innerText.trim() || dataElement.innerHTML.trim();
// Create a JSON object with the data
sShowDetails = { data };
// Log the output in JSON format
console.log("JSON Output:", JSON.stringify(sShowDetails, null, 2));
// Write the output as a new line in the console (writeLine equivalent in web)
const outputLine = document.createElement("div");
outputLine.textContent = `Output Data: ${JSON.stringify(sShowDetails, null, 2)}`;
document.body.appendChild(outputLine);
} else {
console.error("Element not found inside the shadow DOM.");
}
} else {
console.error("Shadow root not found.");
}
} else {
console.error("Shadow host not found.");
}
} catch (error) {
console.error("Error retrieving data:", error);
}
// Return sShowDetails
return sShowDetails;
})();
The output of the script is displayed correctly in the Chrome browser’s console, as shown below:
However, when I run the same script in OpenRPA’s Execute Script activity, the output is not shown in the Output Panel as seen in the screenshot below:
How can I get the output of this JavaScript script to appear in OpenRPA’s Output Panel? I’m looking for guidance on how to handle this situation, and if there are any OpenRPA-specific methods for logging output that would capture the result.
Any help would be appreciated!
Thanks,
Ashok S