Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable proxy via Python for Selenium with headless Chrome

I'm using Chrome with Selenium in Python 2.7.

I've tried to run Chrome in headless mode but it slows down my tests significantly.

One workaround shall be to disable the proxy settings but I don't know how to do it in python.

This is my code so far:

from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument('headless')
chrome_options.add_argument('--hide-scrollbars')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('???') # which option?
self.driver = webdriver.Chrome("C:\Python27\Scripts\chromedriver.exe", chrome_options=chrome_options)

Does anyone know how to solve this?

like image 854
Joern Boegeholz Avatar asked Oct 20 '25 13:10

Joern Boegeholz


1 Answers

Try this:

chrome_options.add_argument('--no-proxy-server')
like image 145
Alexey Dolgopolov Avatar answered Oct 22 '25 04:10

Alexey Dolgopolov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!