How do I pass options to the Selenium Chrome driver using Python?

k107 picture k107 · Oct 2, 2012 · Viewed 97.4k times · Source

The Selenium documentation mentions that the Chrome webdriver can take an instance of ChromeOptions, but I can't figure out how to create ChromeOptions.

I'm hoping to pass the --disable-extensions flag to Chrome.

Answer

k107 picture k107 · Oct 2, 2012

Found the chrome Options class in the Selenium source code.

Usage to create a Chrome driver instance:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--disable-extensions")
driver = webdriver.Chrome(chrome_options=chrome_options)