Disable image load in Chrome with Selenium in Python

Viewed 1544

How to Disable The load of images in chrome

browser.get("chrome://settings/content/images")
time.sleep(5)
images = browser.find_element_by_id('addSite')
images.click()
text = browser.find_element_by_css_selector("[id='input']")
text.send_keys("https://www.instagram.com/")
accept = browser.find_element_by_xpath("//button[text()='Añadir']")
accept.click() 

i was trying to go to the settings page in chrome and click in blocked sites and add instagram, so it will block the images in instagram, but it cant find the buttons on the page. Anyone knows another way? i tried to use an extension but its .crx and chrome only likes .crx3

1 Answers
option = webdriver.ChromeOptions()
chrome_prefs = {}
option.experimental_options["prefs"] = chrome_prefs
chrome_prefs["profile.default_content_settings"] = {"images": 2}
chrome_prefs["profile.managed_default_content_settings"] = {"images": 2}
browser = webdriver.Chrome(chrome_options=option)
Related