質問

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!

役に立ちましたか?

解決

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)
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top