Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

153
Vistas
Await promises affecting code sequence. Javascript Script using Puppeteer and MSAL login

I am writing a script using "Puppeteer" and when using headless = false, the script stops after I enter my password in MSAL, it stalls and doesn't finish the rest of the script. It stalls on line 37 (I highlighted the code line in caps as a comment)

const puppeteer = require('puppeteer');

msal = async () => {
    // Set up page
    const browser = await puppeteer.launch({
        headless: false
    });
    const page = await browser.newPage();
await page.goto('https://testurl.com');

// Login from Landing Page
await page.waitForSelector('#login-btn', {
    visible: true
});
const loginButton = await page.$('#login-btn');
await Promise.all([
    await loginButton.click(),
    page.waitForNavigation(),
]);

// Login MSAL info
await page.waitForSelector('#i0116', {
    visible: true
});
// Email
const emailInput = await page.$('#i0116');
await emailInput.type('testuser@hello.com');
const submitButton = await page.$('#idSIButton9');
await submitButton.click();
// Password
await page.waitForSelector('#i0118', {
    visible: true
});
passwordInput = await page.$('#i0118');

await passwordInput.type('password123');

// HERE IS WHERE IT STALLS

const submitButton2 = await page.$('#idSIButton9');
await submitButton2.click()
const submitButton3 = await page.$('#idSIButton9');
await submitButton3.click()
// page.waitForNavigation();
// console.log(page.url());

await page.waitForSelector('#welcome-banner-title-h2', {
    visible: true
});

// Validate login via url via redirect        
if (page.url() != 'https://testurl.com') {
    console.error('login failed!');
} else {
    console.log('login succeeded');
}
await page.close();
}
msal();

UPDATE

  1. The cursor just blinks on the password input field.
  2. There is no activity in the console or network tab in inspector.
  3. The id i0118 is the correct id assigned for that DOM object.
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda