So i'm making a project with puppeteer, which logs in to Instagram and takes 2 lists from the profile (followers and following) and then compares them.
So far my app logs in to Instagram, then goes to "my Profile" opens the first list "followers" but in order to get the full list, i need to scroll down, since only near 10 followers appear at first. And as you scroll down more and more followers appear.
So once the followers list open, i need to automatically scroll down for as long as new followers keep appearing.
(note that every time you scroll to the bottom only "like" 10-15 new followers appear at a time. So if i have 200 followers i need to scroll down to the bottom of the list a couple times)
Here is my code, and the problem is that the scroll down part is not working.
const myUsername = ""; // put username here
const myPassword = ""; // put password here
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
await page.goto('https://www.instagram.com/accounts/login/', {waitUntil: 'networkidle2'});
//login to instagram
await page.waitForSelector('input[name="username"]');
await page.type('input[name="username"]', myUsername);
await page.type('input[name="password"]', myPassword);
await page.click('button[type="submit"]');
//once login is complete go to profile
await page.waitForNavigation();
await page.goto('https://www.instagram.com/' + myUsername, {waitUntil: 'networkidle2'});
await page.click('a[href="/' + myUsername +'/followers/"]');
//once you click on your followers, scroll down to get the full list
await page.waitForNavigation();
await page.waitFor(3000);
const element = 'div[role="dialog"] > div:nth-child(2)';
await page.waitForSelector('div[role="dialog"] > div:nth-child(2) > ul');
element.scrollIntoView(true);
//await browser.close();
})();