karma-runner / karma-sauce-launcher

A Karma plugin. Launch any browser on SauceLabs!
MIT License
199 stars 103 forks source link

Pass custom command line flags #240

Closed vitalets closed 3 years ago

vitalets commented 3 years ago

I'm trying to pass custom Chrome flags as well as for usual karma-chrome-launcher. But seems it's not working. Example config:

chrome_latest_win10: {
      base: 'SauceLabs',
      browserName: 'Chrome',
      platform: 'Windows 10',
      version: 'latest',
      flags: [
        '--flag-switches-begin',
        '--disable-features=WebRtcHideLocalIpsWithMdns',
        '--flag-switches-end'
      ]
    },

Is it possible to pass custom cli arguments?

wswebcreation commented 3 years ago

Hi @vitalets

I assume you mean chrome options here. If you so you need to provide them through a 'goog:chromeOptions' object.

vitalets commented 3 years ago

@wswebcreation thank you!

This works:

'goog:chromeOptions': {
  args: [
      '--flag-switches-begin',
      '--disable-features=WebRtcHideLocalIpsWithMdns',
      '--flag-switches-end'
  ]
}

For other browsers key names will be moz:firefoxOptions and ms:edgeOptions.

wswebcreation commented 3 years ago

You're welcome

ruchirrs commented 3 years ago

Hi All for me the google chrome options work, however the firefox options do not seem to work. Can someone send me their sample log file? Below is what i used. I am basically trying to get video to autoplay when my script runs, however

Chrome options which works: "goog:chromeOptions": { args: [ '--autoplay-policy=no-user-gesture-required' ] }, firefox options which do not work

"moz:firefoxOptions": {
        args: [
          // '--media.autoplay.allow-extension-background-pages=true',
          '--media.autoplay.enabled.user-gestures-needed=false',
          '--media.allowed-to-play.enabled=true',
          '--media.autoplay.allow-extension-background-pages=true',
          '--media.autoplay.allow-muted=true',
          '--media.autoplay.block-webaudio=false',
          '--media.autoplay.default=-0',
          '--media.block-autoplay-until-in-foreground=false'
        ]
      },
vitalets commented 3 years ago

Hi All for me the google chrome options work, however the firefox options do not seem to work. Can someone send me their sample log file? Below is what i used. I am basically trying to get video to autoplay when my script runs, however

Chrome options which works: "goog:chromeOptions": { args: [ '--autoplay-policy=no-user-gesture-required' ] }, firefox options which do not work

"moz:firefoxOptions": {
        args: [
          // '--media.autoplay.allow-extension-background-pages=true',
          '--media.autoplay.enabled.user-gestures-needed=false',
          '--media.allowed-to-play.enabled=true',
          '--media.autoplay.allow-extension-background-pages=true',
          '--media.autoplay.allow-muted=true',
          '--media.autoplay.block-webaudio=false',
          '--media.autoplay.default=-0',
          '--media.block-autoplay-until-in-foreground=false'
        ]
      },

This code works for me for Firefox:

      'moz:firefoxOptions': {
        prefs: {
          'media.peerconnection.ice.obfuscate_host_addresses': false
        }
      }