Webdriverio: Disable image with chromedriver

Created on 26 Jan 2016  ·  4Comments  ·  Source: webdriverio/webdriverio

I want to disable image loading for faster page loading, I tried below code, but it does not work:

var webdriverio = require('webdriverio');
var options = {
    desiredCapabilities: {
        browserName: 'chrome',
        'prefs': {
            'profile':{
                'default_content_setting_values': {'images': 2}
            }
        }
    }
};
var client = webdriverio.remote(options)

What is the best way to set browser settings? I know that there is a method to provide a data_dir parameter for browser. I think using data_dir is not very flexible, so I did not even try it.

Most helpful comment

I haven't tried this, but you might have luck adding the same thing inside a chromeOptions block:

var options = {
    desiredCapabilities: {
        browserName: 'chrome',
        'chromeOptions': {
            'prefs': {
                'profile':{
                    'default_content_setting_values': {'images': 2}
                }
            }
        }
    }
};

That's what seems to be implied by https://sites.google.com/a/chromium.org/chromedriver/capabilities.

All 4 comments

I haven't tried this, but you might have luck adding the same thing inside a chromeOptions block:

var options = {
    desiredCapabilities: {
        browserName: 'chrome',
        'chromeOptions': {
            'prefs': {
                'profile':{
                    'default_content_setting_values': {'images': 2}
                }
            }
        }
    }
};

That's what seems to be implied by https://sites.google.com/a/chromium.org/chromedriver/capabilities.

Yep - worked for me!

Thanks for investigating @georgecrawford !

If it does work it works only on explicit <img> tags not CSS-loaded image resources. Am I correct?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pfluegs picture pfluegs  ·  4Comments

KOPTE3 picture KOPTE3  ·  3Comments

kiraLinden picture kiraLinden  ·  3Comments

dahumadasg picture dahumadasg  ·  3Comments

grofit picture grofit  ·  4Comments