I am looking for a solution to handle basic authentication popup (with puppeteer=5.2.1). My scenario is as below.
1. Launch an application
2. Click on a button on the home page
3. It opens a new window (saml) which ask us to enter email
In new window,
4. Enter email
5. click on Next button
6. Basic authentication popup appears (=> here I need help to handle the popup)
Here is the code to reach until 3rd step. I am able to get reference to 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 various options I tried to handle basic auth popup in 6th step.
Option-1: using page.authenticate()
await samlPage.authenticate({username: `${myuser}`, password: `${mypass}`});
await samlPage.type(samlSignInUserTextField, `${myuser}`);
await samlPage.click(samlSignInNextButton);
=> It continued to load and next page is not displayed.
Option-2: using 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);
=> Still basic authentication popup appears.
Option-3: Tried to handle auth popup using page.keyboard().
await samlPage.keyboard.type("user@domain.com");
await samlPage.keyboard.press("Tab");
await samlPage.keyboard.type("mypassword");
await samlPage.keyboard.press("Enter");
=> But it is not typing anything into the fields.
Can someone please help me on this?