Hi i'm trying to use puppeteer synchronously but i'm getting an error when i try to access the click method on the page:
let _browser;
let _page;
puppeteer
.launch({ headless: false, defaultViewport: null })
.then((browser) => (_browser = browser))
.then((browser) => (_page = browser.newPage()))
.then((page) => page.goto('https://instagram.com'))
.then(() => _page)
.then((page) => page.waitForTimeout(3000))
.then((page) => page.click('button[class="aOOlW HoLwm "]'))
.then(() => _browser.close());
I get an error on button click (.then((page) => page.click('button[class="aOOlW HoLwm "]'))):
file:/index.js:38 .then((page) => page.click('button[class="aOOlW
HoLwm "]')) ^TypeError: Cannot read properties of undefined (reading 'click') at file::/index.js:38:24
Is there a way to access the click method of page synchronously? Why am I getting that error?