How do you disable Google Chrome SafeBrowsing while using Puppeteer?

132 Views Asked by At

I've been using Puppeteer to automate user journeys through various web portals and one of the things I've run into is the constant popups caused by using bad credentials. In this case, the browser told me that the password I'd just logged in with had been seen in a data breach. Now, this isn't a concern because they are testing credentials. However, I can see how this can easily mess up the script for other people where they can't just change their credentials.

Here is the dialog that I've been trying to get rid of:

Data breach dialog

The main problem is that the dialog completely disrupts the Puppeteer script and causes it to fail. I don't know how to auto-dismiss these popups, but I would assume these would still mess up the script while it's trying to fill in fields and click buttons. Worse still, when running the script in headless mode, it will not be readily apparent to the user that the script failed at the login page because of their bad password.

I know you can prevent this dialog from showing by going into Chrome Settings and disabling SafeBrowsing (chrome://settings/security), however, this is not something that then works when using Puppeteer as it is configured differently. I searched through this huge list of command line arguments for Google Chrome and I couldn't find anything specific to specifically disabling password breach dialogs or disabling SafeBrowsing entirely.

I saw there was a Windows-specific trick where you could write a Group Policy to the Windows Registry, but I need the solution to be cross-platform (i.e. also work on MacOS and Linux). Also, it's important that the solution isn't reliant upon using my user data directory as I need this script to work on other computers and even remote servers when I'm running Puppeteer in headless mode.

Example code which is enough to run into the issue. Note the main problem is not the code, but the use of a common password found in a data breach.

import puppeteer from 'puppeteer';

async function launchPuppeteer() {
    const browser = await puppeteer.launch({
        defaultViewport: null,
        executablePath: '/path/to/chrome/executable',
        headless: false,
        args: [ /* Chrome command line args go here */ ]
    });
    const page = await browser.newPage();
    // use page here . . .
}

Is there any command line argument for Chrome, or functionality within Puppeteer, to disable SafeBrowsing?

1

There are 1 best solutions below

0
a hmed.gamer_1_ On

I do not know the exact reason, but when I used this args, this error was resolved after that

[ '--autoplay-policy=user-gesture-required', '--disable-backgrounding-occluded-windows', '--disable-breakpad', '--disable-client-side-phishing-detection', '--disable-component-update', '--disable-default-apps', '--disable-dev-shm-usage', '--disable-domain-reliability', '--disable-extensions', '--disable-features=AudioServiceOutOfProcess', '--disable-hang-monitor', '--disable-notifications', '--disable-offer-store-unmasked-wallet-cards', '--disable-popup-blocking', '--disable-print-preview', '--disable-prompt-on-repost', '--disable-renderer-backgrounding', '--disable-setuid-sandbox', '--disable-speech-api', '--disable-sync', '--hide-scrollbars', '--ignore-gpu-blacklist', '--metrics-recording-only', '--mute-audio', '--no-default-browser-check', '--no-first-run', '--no-pings', '--no-sandbox', '--no-zygote', '--password-store=basic', '--use-gl=swiftshader', '--use-mock-keychain', ]