Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

157
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda