I am trying to make a script that will load up facebook, type in an email and password and automatically log in. However, when opening the url "https://facebook.com/login", after around 0.5s, a cookie notice appears. I am trying to make Puppeteer click on the 'Accept' button but it doesn't want to do it for some reason?
So because of this, the program never advances because it cannot click the button. Could somebody look at my code and let me know where I am going wrong?
index.js (relevant portion):
let browser = await puppeteer.launch({
headless: false
});
let page = await browser.newPage();
if (Object.keys(cookies).length) {
await page.setCookie(...cookies);
await page.goto('https://www.facebook.com/');
} else {
await page.goto('https://www.facebook.com/login', {
waitUntil: 'networkidle0'
});
await page.waitForNavigation('load')
// await page.waitForSelector('#u_0_i_6I', {
// visible: true
// })
// I TRIED THE ABOVE COMMENTED OUT CODE, DIDN'T WORK
await delay(3000)
// SO I TRIED MANUALLY WAITING 3 SECONDS FOR THE NOTICE TO LOAD IN BEFORE I CLICK IT
await page.click('#u_0_i_6I') //COOKIE NOTICE ACCEPT BUTTON ID