How to block third party party JS using chrome profile 'managed_javascript_blocked_for_urls'

335 Views Asked by At

I have an automation suite running on an e-commerce website, which has a lot of third party JS content I do not want to load while running my tests. I am looking for ways to block the unwanted content on the website to reduce the page load time.

I was able to block images using the following block of code

{
  browserName: 'chrome',
  acceptInsecureCerts: true,
  chromeOptions: {
    'prefs': {
      'profile': {
         'default_content_setting_values': {
            'images': 2,
          },
       },
     },
   }
}

However, when I try to pass the the URLs I want to block using 'managed_javascript_blocked_for_urls', it does not work. This is how I tried passing the values to this flag:

'default_javascript_blocked_for_urls': [ "www.googletagservices.com" ] 'managed_javascript_blocked_for_urls': [ "www.googletagservices.com" ] 'default_javascript_blocked_for_urls': { "www.googletagservices.com" : 2 }

However, none of those combinations worked. Anyone who has used this with webdriverIO and would be able to help?

0

There are 0 best solutions below