【问题标题】:How to disable Flash in Firefox with Selenium in Python?如何在 Python 中使用 Selenium 在 Firefox 中禁用 Flash?
【发布时间】:2013-04-30 16:17:55
【问题描述】:

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

非常感谢!

【问题讨论】:

    标签: python browser selenium selenium-webdriver web-testing


    【解决方案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)
    

    【讨论】:

    • 优秀。非常感谢!
    • 您能否指定更多细节,例如 FF 和 selenium 版本?
    猜你喜欢
    • 2010-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-14
    • 1970-01-01
    • 1970-01-01
    • 2018-08-08
    相关资源
    最近更新 更多