'Is there a way to dismiss a native authentication dialog when using Playwright?

I'm using Playwright (Java) to drive a particular third-party Web site, the first page of which apparently containing two images which are password protected; this causes a sequence of basic-authentication dialogs to open when the page loads.

I'd like the script to dismiss these dialogs (cancel), rather than providing any credentials, and then continue working with the page. But as it stands now, the page.navigate() blocks and eventually times out, unless I cancel these dialogs manually with the mouse.

Note that this is the native browser dialog, not anything generated from js on the page.

Is this possible with Playwright?



Solution 1:[1]

Interestingly, I was able to work around this by disabling images entirely in Chrome, which might have other (performance) benefits, too.

Added this to the array of Chrome startup arguments:

--blink-settings=imagesEnabled=false

Of course, this only solved this specific case, in which the login prompts were being triggered by image URLs.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1