Google Safe Browsing shows client side warning page when browsing to a malicious web site.
For example, navigating to https://testsafebrowsing.appspot.com/s/malware.html will display:
However, when using puppeteer this warning page is not shown.
Is it possible to enable this error screen in puppeteer, or to detect it will be shown if using the browser?
I have tried to:
Use the local Chrome instead of Chromium
set ignoreDefaultArgs to true (run without puppeteer default flags):
const browser = await puppeteer.launch({
executablePath: '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome',
ignoreDefaultArgs: true,
});
Played with various possible related flags see here
However the warning page was never displayed.
Did you try launching puppeteer with the 'userDataDir' argument?
Using a predefined user directory should enable web security capabilities.
const browser = await puppeteer.launch({
executablePath: '/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome',
ignoreDefaultArgs: true,
userDataDir: '/Users/<user>/Library/Application Support/Google/Chrome'
});
Related
// executablePath is specified
const browser = await puppeteer.launch({
executablePath: '/path/to/chrome'
});
// // executablePath is not specified
const browser = await puppeteer.launch();
// This will not work.
// console.log('executablePath is', browser.executablePath)
If we do not specify a value for the executablePath option, Puppeteer will try to find the default installation of Chrome or Chromium on the system. On Windows, this is usually C:\Program Files (x86)\Google\Chrome\Application\chrome.exe. On macOS and Linux, Puppeteer will try to use the chrome or chromium executable in the PATH.
How we can find out which executable is getting used by Puppetter in Puppeteer script itself?
https://pptr.dev/api/puppeteer.puppeteernode.executablepath
const puppeteer = require('puppeteer')
console.log(puppeteer.executablePath())
Example output on my node-18 docker image is
root#021100c40ec4:/usr/src/app# node -e "console.log(require('puppeteer').executablePath())"
/root/.cache/puppeteer/chrome/linux-1069273/chrome-linux/chrome
I'm using the plugin gatsby-remark-mermaid which also includes installing puppeteer. The mermaid diagrams are rendered properly on my end, however it gets an error on the build. Here is the error message:
Failed to launch the browser process!
/tmp/build/node_modules/puppeteer/.local-chromium/linux-970485/chrome-linux/chrome: error while loading shared libraries: libnss3.so: cannot open shared object file: No such file or directory
I looked into the documentation and since I'm running it on Heroku, I must include this configuration:
puppeteer.launch({ args: ['--no-sandbox'] });
I tried using it on gatsby-browser.js like this, but I only got errors instead.
const puppeteer = require('puppeteer')
const browser = await puppeteer.launch({ args: ['--no-sandbox'] })
Where do I need to put this configuration for it to work?
I tried to launch chrome with puppeteer but it gave me this error
Error: Failed to launch the browser process! spawn //C://Program Files (x86)//Google//Chrome//Application ENOENT
This is the code I used
const puppeteer = require('puppeteer')
const browser = await puppeteer.launch( { headless: false,
executablePath: '//C://Program Files (x86)//Google//Chrome//Application' })
So how can I launch chrome with puppeteer?
The path you gave is invalid in this format. If you are on Windows (which I suppose based on your currently given path) (1) you should use double backslashes \\, (2) but you shouldn't start your path with slashes nor backslashes. (3) Also you need the exact executable file as well at the end: chrome.exe.
The process goes like this: You can retrieve the exact executable path at your Chrome's chrome://version/ page, then you just need to escape each backslashes with another backslashes.
Correct usage:
C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe
I'd like to add, perhaps what you want is using the package chrome-launcher which takes care of running the chrome browser.
You can then use puppeteer.connect() to connect the puppeteer-core library to the browser opened and instrument it.
This is what worked for me on Windows
const browser = await puppeteer.launch({
headless: false,
executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe',
})
The slashes should be forward facing
I'm writing a protractor test that opens new tabs (in Chrome).
because Chrome settings are per user and the instance that opened by Protractor is anonymous - the pop-up settings are set to block all, so the test fails. I want to set setting for all users.
I've understood that I suppose to set the 'master_preference' file that supposed to be located under /library/Google (on Mac OX) and I don't find that file. Any ideas?
You need to let your Chrome know that you don't want the popups being blocked by setting the --disable-popup-blocking argument:
capabilities: {
browserName: 'chrome',
chromeOptions: {
args: ['disable-popup-blocking']
}
},
Task: Debug other extensions using chrome debugger api.
Expected Output: http request logs made by other installed extensions.
Method: Running chrome webdriver with selenium in python setting flag chromeopts.add_argument('--silent-debugger-extension-api' ). Inside my extension, On event chrome.management.onInstalled using following code
chrome.debugger.attach({ extensionId: info.id }, version, onAttach.bind(null, info.id));
chrome.debugger.sendCommand({ extensionId: info.id }, "Network.enable");
chrome.debugger.onEvent.addListener(onEvent);
Error: Cannot access a chrome-extension:// URL of different extension
To debug the background page of another extension, you need to set two flags:
--silent-debugger-extension-api
To allow debugging of background pages.
--extensions-on-chrome-urls
To allow debugging of other extensions.