Selenium Chrome Proxy Authentication in Python
Setting chromedriver proxy with Selenium using Python
If you need to use a proxy with python and Selenium library with chromedriver you usually use the following code (Without any username and password:
This works fine unless proxy requires authentication. if the proxy requires you to log in with a username and password it will not work. In this case, you have to use more tricky solution that is explained below. By the way, if you whitelist your server IP address from the proxy provider or server it should not ask proxy credentials.
HTTP Proxy Authentication with Chromedriver in Selenium
To set up proxy authentication we will generate a special file and upload it to chromedriver dynamically using the following code below. This code configures selenium with chromedriver to use HTTP proxy that requires authentication with user/password pair.
Function get_chromedriver returns configured selenium webdriver that you can use in your application. This code is tested and works just fine.
Read more about onAuthRequired event in Chrome.