【问题标题】:Disable images in Selenium ChromeDriver在 Selenium ChromeDriver 中禁用图像
【发布时间】:2012-02-24 15:15:49
【问题描述】:

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

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

【问题讨论】:

  • 我在 Chrome 命令行开关列表中看不到“禁用图像”。我确实在快速谷歌搜索中看到提到“--disable-images”,但它似乎不起作用。 peter.sh/experiments/chromium-command-line-switches
  • 是的。有几个地方提到。确实遇到过那个网站,但不确定它是否是一个完整的列表。

标签: c# google-chrome selenium selenium-chromedriver


【解决方案1】:

我遇到了同样的问题,我找到了答案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);

【讨论】:

  • 这是如何添加到chrome驱动的?它创建的三个变量会发生什么变化?
猜你喜欢
  • 1970-01-01
  • 2018-12-29
  • 2017-02-23
  • 2021-06-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-10-02
相关资源
最近更新 更多