Or Assayag
Or Assayag

Reputation: 6346

Puppeteer.js - Remove Chrome background messages

I'm using the following Puppeeter.js (puppeteer-extra is extended package of Puppeeter.js) code in order to create my browser:

const puppeteerExtra = require('puppeteer-extra');
const browser = await puppeteerExtra.launch({
    headless: false,
    ignoreDefaultArgs: ['--enable-automation'],
    args: [
        '--no-sandbox',
        '--disable-setuid-sandbox',
        '--disable-dev-shm-usage',
        '--start-maximized'
    ]
});

But I keep getting messages like 'Chrome isn't your default browser' Or 'Save credentials' dialog after login.
How can I permanently remove these messages? Images attached to see what I'm talking about.
Thanks everyone.
Image 1: enter image description here Image 2:
enter image description here

UPDATE:
I use ignoreDefaultArgs: ['--enable-automation'] in order to remove the Chrome message on top "Chrome is being controlled by automated test software".
Image 3: enter image description here I want to keep disabling this message (image 3), and also remove theses messages (images 1-2).

Upvotes: 0

Views: 2348

Answers (1)

yeniv
yeniv

Reputation: 1639

Using the ignoreDefaultArgs: ['--enable-automation'] is causing both of the issues. By default, Puppeteer launches Chrome using the --enable-automation flag which tells Chrome to not prompt to Save password and not show the prompt for default browser check (among other things). More details here

By specifying this flag in ignoreDefaultArgs, you are telling Chrome that it is not being run in automation and so it shows up these prompts. So removing this should solve the problem.

Update based on update in Question

Not sure if this suits your usecase, but another possible option is to make Chrome remember your choice by using the --user-data-dir flag which would make Chrome store the preference (and other stuff) to a persistent location.

So basically:

  1. Add '--user-data-dir=c:/temp2/' to the args in puppeteerExtra.launch call. You might want to change the location there.
  2. Launch your script once, which would open up Chrome and it would create the directory mentioned in --user-data-dir to save the data. Here, manually close the banner for default browser check. And then manually open the browser settings and disable "Offer to save passwords" option. These preferences would get saved.
  3. Close the browser/script.

Subsequently, whenever the script launches Chrome, it uses the preferences you saved and won't present these 2 prompts to user.

Upvotes: 2

Related Questions