zvikachu zvikachu - 1 year ago 245
Java Question

Java Selenium Chrome driver - Disable image loading

I am trying to run chrome driver without loading any images for obvious reasons.

i found a piece of code online but i think it's outdated

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

HashMap<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_settings", images);

ChromeOptions options =new ChromeOptions();
options.setExperimentalOption("prefs", prefs);

DesiredCapabilities chromeCaps = DesiredCapabilities.chrome();
chromeCaps.setCapability(ChromeOptions.CAPABILITY, options);

driver = new ChromeDriver(chromeCaps);

does not work at all..

any help would be greatly appriciated

Answer Source

I found a small plugin that does a really good job

ChromeOptions op = new ChromeOptions();
    op.addExtensions(new File("C:\\whatever\\Block-image_v1.0.crx"));
    driver = new ChromeDriver(op);

if anyone else is interested, you can grab it here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download