feat: return innerText

This commit is contained in:
karishmas6
2024-07-15 19:29:17 +05:30
parent e8f09d1be0
commit 9628ab9d23

View File

@@ -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.