Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I need to allow flash content in an automated manner in Python. I tried using Selenium in Python to do so but could not manage. The issue is that browsers stopped supporting settings that always allow flash content. Moreover, 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?

Here is an image of the Firefox message that I need to somehow access: https://i.stack.imgur.com/VYuRV.png

like image 349
Kasper Nicholas Avatar asked Dec 02 '19 10:12

Kasper Nicholas


2 Answers

"...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.

like image 51
VC.One Avatar answered Oct 16 '22 13:10

VC.One


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()
like image 34
undetected Selenium Avatar answered Oct 16 '22 11:10

undetected Selenium