0

I've been working on a personal project, and I find myself unable to work with both headless, and utilize a browser extension at the same time. I can only choose one or the other.

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options

ghostery = "D:\\Coding\\python\\web\\WebPlayer\\ghostery.crx"
opts = Options()
opts.add_extension(ghostery)
opts.add_argument("--headless")
driver = webdriver.Chrome(options=opts)

This is what I currently have. Commenting either the opts.add_extension() line or opts.add_argument() line will make it work perfectly. But I want to be able to use both features at the same time. I have tried alternatives such as:

# same imports as above
ghostery = "D:\\Coding\\python\\web\\WebPlayer\\ghostery.crx"
opts = Options()
opts.add_extension(ghostery)
opts.headless = True
driver = webdriver.Chrome(options=opts)

This does not work. I have had other alternatives as well, but they all don't work for the same reasons as mentioned above.

Edit: I decided to use Firefox instead which fixed the issue. I can now use headless and addons at the same time.

YJH16120
  • 419
  • 1
  • 4
  • 15
  • Does this answer your question? [Is it possible to run Google Chrome in headless mode with extensions?](https://stackoverflow.com/questions/45372066/is-it-possible-to-run-google-chrome-in-headless-mode-with-extensions) – Calumah Nov 01 '20 at 12:49
  • Sorry for the late reply. But no, I've seen this before, and tried to use the given solution. But it didn't work. – YJH16120 Nov 03 '20 at 12:59

0 Answers0