3

I am trying to use saucelabs to automate taking screenshots of several sites to make sure that changing code doesn't break things. I'm programming using webdriver for python and need to disable flash on chrome, firefox and IE. I've tried to find the answers online but none of them seem to be for disabling flash, only interacting with flash objects.

dustyjuicebox
  • 259
  • 2
  • 9
  • So can you share what you have tried? – Amey Jun 14 '13 at 17:06
  • That's the thing, I have no real indication of where to try. Selenium lets you load a custom firefox profile but saucelabs isn't as nice. Also that only works for firefox. This is less of a debug question and more of a "Has anyone actually done this before?" – dustyjuicebox Jun 14 '13 at 17:44
  • 1
    @user2486903, I haven't tried it before but one thing you could try is passing down the parameter that disables the bundled version of Flash: http://peter.sh/experiments/chromium-command-line-switches/#disable-bundled-ppapi-flash – Arran Jun 15 '13 at 09:40
  • 1
    According to the [Sauce Labs docs on custom profiles](https://saucelabs.com/docs/additional-config) (scroll down to "Custom Firefox Profiles"), this is built into the FirefoxProfile class for WebDriver: https://code.google.com/p/selenium/wiki/FirefoxDriver. For Chrome, look into setting command line args as a previous commenter has suggested. – Jonathan Lipps Feb 12 '14 at 01:09

1 Answers1

1

The below code will work for chrome, it disables the flash and sets the default download directory to a different folder.

from selenium.webdriver.chrome.options import Options   
def _disable_flash_caps(self):
      chromeOptions = Options()
      # prefs = {"download.default_directory" : "C:\\temp", "profile.managed_default_content_settings.plugins": 2}
      prefs = {"download.default_directory" : "C:\\temp", "plugins.plugins_disabled": ["Adobe Flash Player"] }
      chromeOptions.add_experimental_option("prefs",prefs)
      return chromeOptions.to_capabilities()

call it with:

if 'browserName' in cap and cap['browserName'] == 'chrome':
   webdriver.Remote.__init__(self, sel_url, self._disable_flash_caps())