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

发布于 2021-01-29 17:40:41

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

非常感谢!

关注者
0
被浏览
48
1 个回答
  • 面试哥
    面试哥 2021-01-29
    为面试而生,有面试问题,就找面试哥。

    您可以使用以下配置文件禁用Flash。

    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)
    


知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看