尝试在ChromeDriver中禁用加载图片。我正在使用以下代码,但它仍在加载图像。有什么建议吗?
DesiredCapabilities capabilities = DesiredCapabilities.Chrome();
capabilities.SetCapability("chrome.switches", new string[1] { "disable-images" });
IWebDriver driver = new ChromeDriver(@"C:\chromedriver\", capabilities);
答案 0 :(得分:2)
我遇到了同样的问题,我找到了答案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);