'Selenium headless chrome with proxy authentication

I'm working on automation of Headless Chrome WebDriver (100.0.48.96.60) using Selenium (4.1.0) and C# (.Net 5.0/Console application). I want to add Proxy Authentication, but nothing seems to work for me.

What I've tried so far:

  1. Selenium's BiDi API: https://www.selenium.dev/documentation/webdriver/bidirectional/bidi_api/#register-basic-auth It's causing 2 exceptions at random times (possibly when opening a url):

System.InvalidOperationException: 'A command response was not received: Fetch.getResponseBody'

OpenQA.Selenium.DevTools.CommandResponseException: 'Fetch.continueRequest: Invalid InterceptionId.'

  1. Proxy Auth Extension: https://github.com/RDavydenko/OpenQA.Selenium.Chrome.ChromeDriverExtensions. It doesn't work with headless chrome.
  2. AutoIT. Also doesn't work in headless chrome I think.
  3. Setting proxy like so:

"username:password@IP:PORT"

All the answers I could find are either not working for headless or just not working anymore. So fell free to leave any idea you can think of about that subject.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source