Use puppeteer to enter password on website that has Dynamic numpad virtual keyboard in nodejs

Viewed 222

I came across a website which I was only able to enter a password in the security control that popped up. How to solve this problem using Puppeteer?

Below is my code:

const puppeteer = require('puppeteer');

const url = 'xxxx';

async function insertPwd() {
  const browser = await puppeteer.launch({
    ignoreHTTPSErrors: true,
    args: ['--ignore-certificate-errors', '--no-sandbox'],
    headless: false,
  });
  let page = await browser.newPage();

  await page.goto(url, { waitUntil: 'load' });

  const selector = '#SIPBox1';
  const input_value = 'abcdefg';

  await page.waitForSelector(selector, { timeout: 5000 });

  const input = await page.$(selector);
  await input.click();

  await page.focus(selector);
  await page.keyboard.type(input_value);
}

insertPwd();
1 Answers

To enter a value in the text box that appears in the hidden block. You first need to call this block with a mouse click

const [xpathElement] = await page.$x(XPATH);
await xpathElement.click();

or

await page.mouse.click(X, Y, { button: 'left' })
Related