Running Adblock Plus webextention on chrome --headless - google-chrome

Chrome version : 58
OS : Ubuntu 16.04
I wanted to take screenshot after blocking ads in chrome --headless mode.For which I have added an entry in default_apps/external_extensions.json for property external_update_url. (Ref : Link)
When I run the application with
google-chrome --remote-debugging-port=9222 --disable-gpu
I am able to see that the adblock plugin is active and blocking adds,While when I tried to run
google-chrome --headless --remote-debugging-port=9222 --disable-gpu
(i.e in headless mode) the adblock plugin is not running or enabled.
I verified the fact by taking screenshot of viewport in both modes. Can anyone please help me to run the adblock plus extension for headless mode.

Headless Chrome does not support extensions, but you can render Chrome on a virtual display. See Is it possible to run Google Chrome in headless mode with extensions?

Related

How to disable CORS in chrome to work with localhost and third party url on window 11 Chrome

I want to access https://third-party-url/ from my localhost But chrome is throwing cors error
I am using window 11 and chrome version : Version 106.0.5249.103 which is latest version till 2022-10-10
Run cmd from Chrome's path.
chrome.exe --disable-web-security --disable-gpu --user-data-dir=~/chromeTemp
This command is only disable cors in the window that opens after running the command. If you close this window, you can use the same command again.

How to run chrome in debug mode with current user profile?

I can do this, if no chrome running on my machine. But if one instance is already running, this command just open a new window without debugging.
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
And in this case I can start chrome only if specify --user-data-dir.
I tried
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222 --no-first-run --no-default-browser-check --user-data-dir=/Users/nazarkalituk/Library/Application\ Support/Google/Chrome/Default
but it didn't help.
You essentially want to set your userDataDir to false in your launch.json. Here is an image of how it would look.
How to set the UserDataDir to false
It will take you the current profile you are currently in.
If it fails to connect to the current profile, or if you want a better option entirely, I recommend going to these links for more info:
https://briandesousa1.wordpress.com/2018/05/12/using-a-chrome-developer-profile-with-visual-studio-code-debugger/
run vscode chrome debugger with its extensions

Does headless Chrome auto update?

Does Chrome update itself when running in headless mode by selenium?
It seems, it is not updating, probably because of --disable-background-networking switch set by Selenium by default. I want to ensure that's indeed the case. If there any reference in documentation explaining either auto-update behavior or meaning of switches and their impact? So far best I've found is list with all command line Chrome switches with some comments, but it is still not clear.
No, Chrome Browser Client doesn't update itself when running in headless mode by selenium.
As per Getting Started with Headless Chrome the Headless Chrome is the server environment where you don't need a visible UI shell.
If you've got Chrome 59+ installed, you start Chrome with the --headless flag as follows:
chrome \
--headless \ # Runs Chrome in headless mode.
--disable-gpu \ # Temporarily needed if running on Windows.
chrome should always point to your installation of Chrome. Of course, the exact location varies from platform to platform.
So until and unless the original Chrome Browser is automatically/manually updated, Chrome Browser Client doesn't get updated.
TL;DR
--disable-background-networking is configured to disable several subsystems which run network requests in the background. This is used when performing network performance testing in order to avoid noise in the measurements.

Chrome Headless Doesn't work

I've read about the Chrome Headless from developers.google said we can run the Google without UI. Quote from that link :
Headless Chrome is shipping in Chrome 59. It's a way to run the Chrome
browser in a headless environment. Essentially, running Chrome without
chrome! It brings all modern web platform features provided by
Chromium and the Blink rendering engine to the command line.
Why is that useful?
A headless browser is a great tool for automated testing and server
environments where you don't need a visible UI shell. For example, you
may want to run some tests against a real web page, create a PDF of
it, or just inspect how the browser renders an URL.
This is really great feature, so I do some experiment with this cool feature. The idea is to taking snapshot as the document site by do call of chrome.exe from Windows Command Prompt, as follow :
chrome --headless --disable-gpu --screenshot https://www.chromestatus.com/
After do several times and following the instruction from these site. I got nothing. I don't get any picture or screenshot with name screenshot.png as document mention it before Running with --screenshot will produce a file named screenshot.png in the current working directory.
From this document also said about version,
Caution: Headless mode is available on Mac and Linux in Chrome 59.
Windows support is coming in Chrome 60. To check what version of
Chrome you have, open chrome://version.
after do some check with suggested before, I run chrome://version on my Chrome on Windows x64 Machine and got some result :
Google Chrome 62.0.3202.94 (Official Build) (64-bit) (cohort: Stable)
Revision 4fd852a98d66564c88736c017b0a0b0478e885ad-refs/branch-heads/3202#{#789}
What wrong? What i missed?
Thanks
After do some experiments. for --screenshot will save the image on the same level as chrome.exe location and that will be mean save on Program Files.
So we need need to combine parameter names and arguments with a =
--screenshot="D:\screen.png" will work, otherwise Chrome writes to it's installation folder. Big design flaw, no software should use it's installation folder as a working directory.
Here are the complete argument :
chrome --headless --enable-logging --disable-gpu --screenshot="D:\screen.png" "https://www.chromestatus.com/"

Headless Chrome in REPL mode doesn't work - spams console with an error

When I try to run Chrome in Headless, REPL mode with:
chrome --headless --disable-gpu --enable-logging --repl
I'm getting an endless spam of
{"result":{"type":"undefined"}}
It's pretty much the same problem as described here:
Headless Chrome REPL not working
But since I'm trying to run it on Windows 7, I'm not sure if that solution applies to me
Edit:
I forgot to add, I'm using a 62.0.3202.94 Chrome version