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
If you're running the headless mode, you can try
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless", "--disable-gpu", "--blink-settings=imagesEnabled=false");
WebDriver driver = new ChromeDriver(options);
Alternatively, you can create a new chrome profile. Disable images by accessing chrome://settings/content on the new profile. Then add the new profile to your chromeDriver options. More info here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With