Note that there are some explanatory texts on larger screens.

plurals
  1. PODisable images in Selenium Google ChromeDriver
    primarykey
    data
    text
    <p>How does one disable images in Google chrome when using it through Selenium and c#?</p> <p>I've attempted 6 ways and none worked. I've even tried the answer on <a href="https://stackoverflow.com/questions/9433109/disable-images-in-selenium-chromedriver">this</a> StackOverflow question, however I think the info in it is out of date.</p> <ul> <li>Chrome driver: V2.2</li> <li>Chrome version: V29.0.1547.66 m</li> <li>Selenium: V2.35</li> </ul> <p>All the attempts I've made don't cause exceptions, they run normally but still display images:</p> <p>Attempt 1:</p> <pre><code>ChromeOptions co = new ChromeOptions(); co.AddArgument("--disable-images"); IWebDriver driver = new ChromeDriver(co); </code></pre> <p>Attempt 2:</p> <pre><code>DesiredCapabilities capabilities = DesiredCapabilities.Chrome(); capabilities.SetCapability("chrome.switches", new string[1] { "disable-images" }); </code></pre> <p>Attempt 3:</p> <pre><code>ChromeOptions co = new ChromeOptions(); co.AddAdditionalCapability("chrome.switches", new string[1] { "disable-images" }); </code></pre> <p>Attempt 4:</p> <pre><code>var imageSetting = new Dictionary&lt;string, object&gt;(); imageSetting.Add("images", 2); Dictionary&lt;string, object&gt; content = new Dictionary&lt;string, object&gt;(); content.Add("profile.default_content_settings", imageSetting); var prefs = new Dictionary&lt;string, object&gt;(); prefs.Add("prefs", content); var options = new ChromeOptions(); var field = options.GetType().GetField("additionalCapabilities", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { var dict = field.GetValue(options) as IDictionary&lt;string, object&gt;; if (dict != null) dict.Add(ChromeOptions.Capability, prefs); } </code></pre> <p>Attempt 5:</p> <pre><code>ChromeOptions options = new ChromeOptions(); options.AddAdditionalCapability("profile.default_content_settings", 2); </code></pre> <p>Attempt 6:</p> <pre><code>Dictionary&lt;String, Object&gt; contentSettings = new Dictionary&lt;String, Object&gt;(); contentSettings.Add("images", 2); Dictionary&lt;String, Object&gt; preferences = new Dictionary&lt;String, Object&gt;(); preferences.Add("profile.default_content_settings", contentSettings); DesiredCapabilities caps = DesiredCapabilities.Chrome(); caps.SetCapability("chrome.prefs", preferences); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload