Reputation: 197
While recording test cases through the browser, the Windows Integrated Authentication window pops up, which needs a username and password for authentication. This is not being recorded by the PlayWright Headless test recorder obviously as this is not browser activity. So to automate the login process, how to handle this popup and authenticate the user, is there any workaround for this.
Could you please let me know if you have encountered this kind of issue earlier for the PlayWright test framework or any other testing framework? Any help on this and highly appreciated.
Upvotes: 3
Views: 2445
Reputation: 11
I faced the same issue, unless the login window even didn't show up at first.
To prevent usage of the current user and start showing the login popup: How to disable Integrated Windows Authentication (IWA) for Chrome via Windows' Control Panel:
(This applies to both Internet Explorer and Chrome since Chrome uses system settings that are managed using Internet Explorer.)
Press Windows' Start button, type "Internet Options" to search, and click the one result, from the control panel
Go to the "Security" tab
Select "Local Intranet" and click on "Custom Level" button
Scroll to the "User Authentication" section at the bottom of the list and select "Prompt for user name and password"
Click Ok, Apply, and Ok to save changes.
Close all instances of the IE browser to make the changes effective. Launch the browser again and access the application. A basic authentication challenge will be served.
To login as desired user: HTTP Authentication
using var context = await Browser.NewContextAsync(new()
{
HttpCredentials = new HttpCredentials
{
Username = "bill",
Password = "pa55w0rd"
},
});
var page = await context.NewPageAsync();
await page.GotoAsync("https://example.com");
Upvotes: 1