小编典典

如何使用Python中的Selenium在Firefox中禁用Flash?

selenium

尝试使用配置文件设置在Firefox中使用Python中的Selenium禁用Flash。这个问题指定了一种通过GUI进行操作的方法,但是对于这种特定用例,最好以编程方式进行操作。具体来说,最好的解决方案是允许在新创建的配置文件对象中禁用Flash。

非常感谢!


阅读 422

收藏
2020-06-26

共1个答案

小编典典

您可以使用以下配置文件禁用闪光灯。

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)
2020-06-26