Currently, I am working with Typescript and Puppeteer. My goal is to extract the innerText from an element.
const data = await page.$eval(selector, node => node.innerText);
However, I encountered an error:
The property 'innerText' is not present in type 'Element'
I attempted to cast it as HTMLElement following advice from this question: error " Property 'innerText' does not exist on type 'EventTarget' "?
const data = await page.$eval(selector, <HTMLElement>(node: HTMLElement) => node.innerText);
In addition, I tried creating my own Interface like this:
interface TextElement extends Element {
innerText: string;
}
Nevertheless, each attempt resulted in the same error stating that innerText is not found in the specific type of element.
The property 'innerText' is not present in type 'HTMLElement'
What could be causing this issue and how can I resolve it?