From 9628ab9d23c3a5b41e3f85f8d8d101cd435b4f6d Mon Sep 17 00:00:00 2001 From: karishmas6 Date: Mon, 15 Jul 2024 19:29:17 +0530 Subject: [PATCH] feat: return innerText --- server/src/workflow-management/selector.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/server/src/workflow-management/selector.ts b/server/src/workflow-management/selector.ts index 957cb3b9..06263950 100644 --- a/server/src/workflow-management/selector.ts +++ b/server/src/workflow-management/selector.ts @@ -74,18 +74,26 @@ export const getElementInformation = async ( tagName: element?.tagName ?? '', hasOnlyText: element?.children?.length === 0 && element?.innerText?.length > 0, - } + innerText: element?.innerText ?? '', // Add innerText to the returned object + }; } + return null; }, { x: coordinates.x, y: coordinates.y }, ); + + if (elementInfo) { + console.log(`Element : ${elementInfo.innerText}`); // Print innerText to the console + } + return elementInfo; } catch (error) { const { message, stack } = error as Error; - logger.log('error', `Error while retrieving selector: ${message}`); - logger.log('error', `Stack: ${stack}`); + console.error('Error while retrieving selector:', message); + console.error('Stack:', stack); } -} +}; + /** * Returns the best and unique css {@link Selectors} for the element on the page.