Reputation: 3427
When using selenium for work behind enterprise firewall, it's necessary to connect to proxy to access internet. However, selenium is returning proxy error even when initializing the webdriver.
from selenium import webdriver
proxy='x.x.x.x:xxx'
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument(f'--proxy-server={proxy}')
driver = webdriver.Chrome(options=chrome_options)
Getting 401
unauthorized error even before visiting any webpage.
Upvotes: 0
Views: 65
Reputation: 3427
After exhaustive search to no avail. Because the webdriver initialization only connects to localhost, it shouldn't need proxy. Adding the '--no-proxy-server' option resolved this issue. This was suggested by chatgpt but not for the right reason.
from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument(f'--no-proxy-server')
driver = webdriver.Chrome(options=chrome_options)
Upvotes: 0