Java Selenium Chrome驱动程序 - 禁用图像加载 [英] Java Selenium Chrome driver - Disable image loading
本文介绍了Java Selenium Chrome驱动程序 - 禁用图像加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在没有加载任何图像的情况下运行chrome驱动程序,原因很明显。
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);
根本不起作用..
任何帮助都会非常适合
推荐答案
我找到了一个非常好的小插件
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
这篇关于Java Selenium Chrome驱动程序 - 禁用图像加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文