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

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


Found the chrome Options class in the Selenium source code.

Usage to create a Chrome driver instance:

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


This is how I did it.

from selenium import webdriverchrome_options = webdriver.ChromeOptions()chrome_options.add_argument('--disable-extensions')chrome = webdriver.Chrome(chrome_options=chrome_options)


Code which disable chrome extensions for ones, who uses DesiredCapabilities to set browser flags :

desired_capabilities['chromeOptions'] = {    "args": ["--disable-extensions"],    "extensions": []}webdriver.Chrome(desired_capabilities=desired_capabilities)