How to log in instagram using Node.js connected with puppeteer?

When writing a bot is faced with the problem of authorization in instagram.What I did so will understand))
const puppeteer = require('puppeteer');
const sleep = (ms)=> new Promise(executor, (res)=>{

(async () => {
const browser = await puppeteer.launch(
headless: false}

const page = await browser.newPage();
await page.goto('');
await page.sleep(ms,5000);
await page.$eval('input[name="username"]',(username)=>
{ username.nodeValue ='test'});
await page.$eval('input[name="password"]',(username)=>
{ username.nodeValue ='1234'})


await page.screenshot({path: 'example.png'})

await browser.close();
April 4th 20 at 00:30
1 answer
April 4th 20 at 00:32
It's simple (I have only confusion about the addiction type page.$eval and'.Igw0E.IwRSH.eGOV_._4EzTm') )
const puppeteer = require('puppeteer');

(async () => {
 const browser = await puppeteer.launch({headless: false});
 const page = await browser.newPage();
 await page.goto('');
 await page.waitFor('input[name="username"]');
 await page.focus('input[name="username"]');
 await page.keyboard.type('login111');
 await page.focus('input[name="password"]');
 await page.keyboard.type('password');
 await new Promise(r => setTimeout(r, 5000));

 await browser.close();

Find more questions by tags Node.jsnpm