2

I've wrote an script that launches a chromedriver instance with an extension.

If I execute the script, chromium is opened and I can see that the extension is in use and working, but if I add the "headless" argument to the script then the extension is not working.

This is the extension: https://tools.google.com/dlpage/gaoptout?hl=es

If it is properly loaded then you're movements are not recorded by Google Analytics.

So I access my own page with the chromium browser loaded by the script and I can't see the access in Google Analytics (in the real time window), but if I add the argument "headless" then I can see the access in real time (so the extension is not working).

I've seen this post: Selenium working with Chrome, but not headless Chrome

But none of the solutions from there work for me.

This is the script:

#!/usr/bin/python


from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException
from http.cookiejar import MozillaCookieJar

import sys,re, pickle, time
from pyvirtualdisplay import Display

display = Display(visible=0, size=(800, 600))
display.start()

if len(sys.argv) < 2:
    print("Usage: getprice.py url")
    sys.exit(0)

URL=sys.argv[1]

options = webdriver.ChromeOptions()

options.add_extension('extension2.crx')
options.add_argument('headless')
driver = webdriver.Chrome(chrome_options=options)

time.sleep(2)
driver.get(URL)
display.stop()
#driver.close()

sys.exit(1)

Any idea on how to solve this?

Thanks in advance.

Sergio P.
  • 68
  • 5
  • 1
    Hi, extensions aren't currently supported in chromedriver as far as I'm aware https://docs.google.com/document/d/1OeUik1MZb1qSQ_Dnf1kIYcyCgLYRZHg1GlZo06bsKx4/edit#heading=h.o067l9gdl1jy Are you using windows or linux? – aml Feb 07 '19 at 15:25

0 Answers0