1

试图在 ChromeDriver 中禁用图像加载。我正在使用以下代码,但它仍在加载图像。有什么建议么?

DesiredCapabilities capabilities = DesiredCapabilities.Chrome();
capabilities.SetCapability("chrome.switches", new string[1] { "disable-images" });
IWebDriver driver = new ChromeDriver(@"C:\chromedriver\", capabilities);
4

1 回答 1

2

我有同样的问题,我在这里找到了答案;

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);
于 2012-12-17T22:26:45.767 回答