禁用硒ChromeDriver图片 [英] Disable images in Selenium ChromeDriver

查看:1080
本文介绍了禁用硒ChromeDriver图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图禁用ChromeDriver加载图像。我用下面的代码,但它仍然加载图像。任何建议

  DesiredCapabilities能力= DesiredCapabilities.Chrome()?; 
capabilities.SetCapability(chrome.switches,新的字符串[1] {禁用的图像});
IWebDriver司机=新ChromeDriver(@C:\chromedriver\功能);


解决方案

我有同样的问题,我找到了答案< A HREF =htt​​p://code.google.com/p/chromedriver/issues/detail?id=20相对=nofollow>此处;

 地图<弦乐,对象> contentSettings =新的HashMap<弦乐,对象>(); 
contentSettings.put(图像,2);

地图<弦乐,对象>喜好=新的HashMap<弦乐,对象>();
preferences.put(profile.default_content_settings,contentSettings);

DesiredCapabilities帽= DesiredCapabilities.chrome();
caps.setCapability(chrome.prefs,喜好);


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);

解决方案

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);

这篇关于禁用硒ChromeDriver图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆