I need assistance with handling a basic authentication popup using puppeteer=5.2.1. My specific scenario is outlined below.
1. Start an application
2. Click on a button on the home page
3. This action opens a new window (saml) requesting email input
Within the new window,
4. Input email address
5. Click on Next button
6. A basic authentication popup appears (=> assistance needed here)
The following code reaches up to the 3rd step, where I am able to access the reference of the new page (saml window)
var browser = await puppeteer.launch({
headless: false, args: ["--start-maximized"]
});
var page = await this.browser.newPage();
await waitUntilElementIsVisible(authMethodDropDown);
await wait(5000);
await page.select(authMethodDropDown, "myoption");
const samlPage = await clickAndWaitForTarget(page, authSubmitButton);
wait(5000);
await samlPage.waitForSelector(samlSignInUserTextField);
Below are the different approaches I have tried to handle the basic auth popup in the 6th step.
Option-1: utilizing page.authenticate()
await samlPage.authenticate({username: `${myuser}`, password: `${mypass}`});
await samlPage.type(samlSignInUserTextField, `${myuser}`);
await samlPage.click(samlSignInNextButton);
=> The loading continues and the next page is not displayed.
Option-2: employing setExtraHttpHeaders
const headers = new Map();
headers.set(
'Autorization',
`Basic ${new Buffer(`${myuser}:${mypass}`).toString('base64')}`
);
headers.set('WWW-Authenticate','Negotiate');
headers.set('WWW-Authenticate','NTLM');
await samlPage.setExtraHTTPHeaders(headers);
=> The basic authentication popup persists.
Option-3: Attempted to manage the auth popup using page.keyboard().
await samlPage.keyboard.type("<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="780d0b1d0a381c1715191116561b1715">[email protected]</a>");
await samlPage.keyboard.press("Tab");
await samlPage.keyboard.type("mypassword");
await samlPage.keyboard.press("Enter");
=> Unfortunately, no text input is recognized in the fields.
If anyone can offer guidance on this matter, it would be greatly appreciated.