I am currently working on a puppeteer script that interacts with my browser extensions and navigates to a specific page. It clicks on a particular extension button and fills in an input
. Unfortunately, I am encountering an issue with the following error message:
throw new Error('Evaluation failed: ' + (0, util_js_1.getExceptionMessage)(exceptionDetails));
^
Error: Evaluation failed: TypeError: time is not a function
at pptr://__puppeteer_evaluation_script__:10:8
at ExecutionContext._ExecutionContext_evaluate (/Users/usr/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:229:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async ExecutionContext.evaluate (/Users/usr/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:107:16)
at async Agent.getPage (/Users/usr/javascript/pending/request_3.js:25:21)
Following this error, the browser closes abruptly. I have researched similar issues that recommend ensuring the use of parentheses around the function newPage or including the await keyword, both of which I have implemented without resolving the problem.
const puppeteer = require('puppeteer');
const EXTENSION = '/Users/usr/Library/Application Support/Google/Chrome/Profile 1/Extensions/gidnphnamcemailggkemcgclnjeeokaa/1.14.4_0';
class Agent {
constructor(extension){
this._extension = extension
}
async runBrowser(){
const browser = await puppeteer.launch({
headless: false,
devtools: true,
args: [
`--disable-extensions-except=${this._extension}`,
`--load-extension=${this._extension}`,
'--enable-automation'
]
})
return browser }
async getPage(textit){
const page = await (await this.runBrowser()).newPage();
await page.goto('chrome-extension://gidnphnamcemailggkemcgclnjeeokaa/popup.html');
const event = await page.evaluate(async () => {
document.getElementById('launch-trace').click()
const someFunc = () => {
const input = document.getElementById('user-trace-id');
input.focus()
input.value=textit
}
const time = setTimeout(someFunc, "3000")
await time()
})
await page.close()
}
}
const test = new Agent(EXTENSION);
test.getPage('bill')