8

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

非常感谢!

4

1 回答 1

7

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

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)
于 2013-05-07T07:05:32.000 回答