Python: How to automate 'Allow' flash player content in Firefox?

To allow flash content in an automated manner using Selenium through Python you need to use an instance of FirefoxProfile() and set_preference() method to configure:

  • dom.ipc.plugins.enabled.libflashplayer.so to true
  • plugin.state.flash to 2

Code Block:

from selenium import webdriver

profile = webdriver.FirefoxProfile()
profile.set_preference("dom.ipc.plugins.enabled.libflashplayer.so","true")
profile.set_preference("plugin.state.flash", 2)
driver = webdriver.Firefox(firefox_profile=profile, executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
driver.get('https://www.google.co.in')
print("Page Title is : %s" %driver.title)
driver.quit()

"...The Allow button cannot be accessed via Selenium for instance because it is not a part of the website or a setting in Firefox. Does anyone know about a potential workaround?"

I don't know your OS but if it was my problem...

  • Try to find a "key press" module to send the A key press into Firefox (ie: the Allow shortcut).

  • Try to send a mouse-click at the coordinates of Allow button.

A good option to try is pyautogui. Once Flash is enabled by such module (clicker or presser) then you can involve Selenium for whatever you needed to do in the enabled Flash.