Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable Flash in Firefox with Selenium in Python?

Trying to disable Flash in Firefox with Selenium in Python, using profile settings. This question specifies a way to do it through the GUI, but it would be better for this particular use case to do it programmatically. Specifically, the best possible solution would allow Flash to be disabled in a newly created profile object.

Thanks very much!

like image 744
Juan Carlos Coto Avatar asked May 06 '13 20:05

Juan Carlos Coto


1 Answers

You can disable flash using the below profile.

from selenium.webdriver.firefox.firefox_profile import FirefoxProfile

    def disableImages(self):
        ## Firefox profile object
        firefoxProfile = FirefoxProfile()

        ## Disable Flash
        firefoxProfile.set_preference('dom.ipc.plugins.enabled.libflashplayer.so',
                                      'false')
        ## Set the modified profile while creating the browser object 
        self.browserHandle = webdriver.Firefox(firefoxProfile)
like image 199
HemChe Avatar answered Nov 09 '22 08:11

HemChe