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

151
Views
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
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!