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