Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

add extension with option headless selenium python

Hi i’d like to add the extension i don't care about cookies on selenium but i have this error :
selenium.common.exceptions.WebDriverException: Message: unknown error: failed to wait for extension background page to load: chrome-extension://fihnjjcciajhdojfnbdddfaoknhalnja/_generated_background_page.html

someone can help me?
Thanks

        self.service = Service(self.path)
        self.chrome_options = webdriver.ChromeOptions()
        self.chrome_options.add_extension("tools/I-don-t-care-about-cookies.crx")
        self.chrome_options.binary_location = os.environ.get("GOOGLE_CHROME_BIN")
        self.chrome_options.add_argument('--headless')
        self.chrome_options.add_argument('--disable-gpu')
        self.chrome_options.add_argument('--no-sandbox')
        self.driver = webdriver.Chrome(service=self.service,options=self.chrome_options)```

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

First, install the extension in your Chrome browser, and check if it works. Then chek the correct extension location. Then you can install it when launching the chromedriver like so:

chrome_options = Options()
[...]
chrome_options.add_argument('--load-extension=/home/user/.config/chromium/Default/Extensions/cjpalhdlnbpafiamejdnhcphjbkeiagm/1.43.0_0')

Selenium documentation can be found at https://www.selenium.dev/documentation/

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading