I cannot use my currently installed extensions in Google Chrome using headless mode. Is there any way to enable them?
An easy way to check if the extensions work is
You can use pyvirtualdisplay to run the chrome with zero display on your server. The best thing is you can run extensions by using this trick.
Here is my implementation:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time
from pyvirtualdisplay import Display
display = Display(visible=0, size=(800, 600))
display.start()
chrome_options = Options()
chrome_options.add_extension("proxy.zip")
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver', chrome_options=chrome_options)
time.sleep(3)
driver.get("https://ipinfo.io/json")
print(driver.page_source)
driver.close()
display.stop()
You need to install xvfb on your server/machine:
sudo apt install -y xvfb
pip install pyvirtualdisplay
Running it on my AWS Server