I am using Typescript with Playwright. I have this code to evaluate javascript.
const CSRFToken = await this.page.evaluate(() => {
return ACC.config.CSRFToken;
});
But I get an error: Cannot find name 'ACC'.ts(2304)
ACC.config.CSRFToken
is something that exists on my page in the script
tag of the DOM.
How can I resolve this?
Thanks!
CodePudding user response:
You can declare a variable ACC in your typescript file and use that variable like following.
declare const ACC: any;
const CSRFToken = await this.page.evaluate(() => {
return ACC.config.CSRFToken;
});