Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
Puppeteer type on prompt

Hello I am trying to login into something like this;
The input fields can be translated into username and password and buttons are login and cancel.


I am trying to type on these fields and press on login button (blue one)

I have tried await page.authenticate({ username: ... , password: ... })
Also I have tried page.on('dialog', async (dialog) => .......) but both of them are not working, it just stays like that.

Or how can I select those fields, i dont know if its even possible since its javascript based function.

enter image description here

and here is my code;

import express from 'express';
import puppeteer from 'puppeteer'; 
import userAgent from 'user-agents'; 

const app = express();
 

const screenshot = 'github3.png';

app.get('/', async (req, res) => {
  const browser = await puppeteer.launch({
    headless: false,
    executablePath: `C:/Program Files (x86)/Google/Chrome/Application/chrome.exe`,
    defaultViewport: null,
    args: ['--start-maximized'],
  });
  const page = await browser.newPage();
  await page.setUserAgent(userAgent.toString());
  page.setDefaultNavigationTimeout(0);
  await page.goto('myUrl...', {
    waitUntil: 'load',
    timeout: 0,
  });
  await page.click('#krbSubmit');

// AFTER THIS CLICK THE PROMPT OPENS ON THE NEXT PAGE

  //   await browser.close();
  res.send('hi');
});

app.listen('5000', console.log('server listening'));
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

I have placed the await page.authenticate({...}) to wrong place. Now, it can proceed.
Here is the final code;

import express from 'express';
import puppeteer from 'puppeteer'; 
import userAgent from 'user-agents'; 

const app = express();
const BLOCKLIST_URL = 'your_url';

const screenshot = 'github3.png';

app.get('/', async (req, res) => {
  const browser = await puppeteer.launch({
    headless: false,
    executablePath: `C:/Program Files (x86)/Google/Chrome/Application/chrome.exe`,
    defaultViewport: null,
    args: ['--start-maximized'],
  });
  const page = await browser.newPage();
  await page.setUserAgent(userAgent.toString());
  page.setDefaultNavigationTimeout(0);
  await page.authenticate({ username: 'username', password: 'password' });

  await page.goto(BLOCKLIST_URL, {
    waitUntil: 'load',
    timeout: 0,
  });
  await page.click('#krbSubmit');

  //   await browser.close();
  res.send('hi');
});

app.listen('5000', console.log('server listening'));
about 4 years ago · Juan Pablo Isaza Report

0

You can use request interception to inject the credentials into the request that the browser makes after clicking #krbSubmit, more precisely the request that brings up the login popup from your screenshot:

await page.setRequestInterception(true);
page.on("request", (request) => {
  var url = request.url();
  if (<url is a generated login URL>)
    request.continue({
      url: url.replace("://", "://username:password@"),
      headers: {
        authorization: "Basic " + Buffer.from("username:password", "base64")
      }
    });
  else
    request.continue();
});
await page.goto('myUrl...', {
  waitUntil: 'load',
  timeout: 0,
});
await page.click('#krbSubmit');

One of the two injection methods (in the URL or in the Authorization: Basic header) should be sufficient.

This assumes that you can detect the generated login URL by a certain pattern. If that fails, you could consider other detection methods, such as counting requests: The first always goes to a fixed URL, the second to the login URL.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!