1

Trying to disable images loading in ChromeDriver. I'm using the following code, however it's still loading the images. Any suggestions?

DesiredCapabilities capabilities = DesiredCapabilities.Chrome();
capabilities.SetCapability("chrome.switches", new string[1] { "disable-images" });
IWebDriver driver = new ChromeDriver(@"C:\chromedriver\", capabilities);
stats101
  • 1,837
  • 9
  • 32
  • 50
  • I can't see "disable-images" in the list of Chrome command line switches. I do see mentions of "--disable-images" in a quick google search, but it doesn't seem to work. http://peter.sh/experiments/chromium-command-line-switches/ – Douglas Feb 24 '12 at 15:21
  • Yep. There is mention of in a few locations. Did come across that site, but was unsure whether it was a comprehensive list. – stats101 Feb 24 '12 at 15:42

1 Answers1

2

I had the same problem and I found the answer here;

Map<String, Object> contentSettings = new HashMap<String, Object>();
contentSettings.put("images", 2);

Map<String, Object> preferences = new HashMap<String, Object>();
preferences.put("profile.default_content_settings", contentSettings);

DesiredCapabilities caps = DesiredCapabilities.chrome();
caps.setCapability("chrome.prefs", preferences);
Lance Roberts
  • 22,383
  • 32
  • 112
  • 130
Sinan Aumarah
  • 81
  • 1
  • 6