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.