Search code examples
pythongoogle-chromeselenium-webdriverheadlessgoogle-chrome-headless

How to use selenium with proxy auth in headless mode?


I'd like to use headless mode with proxy auth login:pass in my python script. I use chrome here.

I have tried creating extension and adding it to chrome, but it works only without headless mode. I was looking for similar issues, but there's no solution like it was unsupoorted. Can anybody give me any tips?


Solution

  • Regular headless mode doesn't support extensions, however, Chrome added a newer headless mode that does. Here's how to set it with Selenium options:

    options.add_argument("--headless=new")
    

    More info: https://github.com/chromium/chromium/commit/e9c516118e2e1923757ecb13e6d9fff36775d1f4

    This assumes you are already using https://stackoverflow.com/a/35293284/7058266 for creating a Chrome extension to set proxy with auth. You may want to see how to set proxy with authentication in selenium chromedriver python? for other ways of setting a proxy.