sngtx
sngtx

Reputation: 49

Is it possible to disable loading images (jpg and png only) on Selenium and Chrome webdrive?

In my efforts to improve performance of my selenium testing application I was wondering if it is possible to avoid loading certain files such as images (jpg and png). The parameter "--disable-images" disable all images, including "gif", which in my canse can be a google analytics tag, and I must capture that.

Upvotes: 3

Views: 3867

Answers (1)

Aldo Suwandi
Aldo Suwandi

Reputation: 392

Yes, you can do it by specifying profile.managed_default_content_settings.image in ChromeOptions. Example:

chromeOptions = webdriver.ChromeOptions()
prefs = {"profile.managed_default_content_settings.images": 2}
chromeOptions.add_experimental_option("prefs", prefs)
driver = webdriver.Chrome(chrome_options=chromeOptions)

As for only for specific image formats, I don't think it's possible

Upvotes: 3

Related Questions