如何在Firefox中使用Python硒禁用闪光? [英] How to disable Flash in Firefox with Selenium in Python?

查看:216
本文介绍了如何在Firefox中使用Python硒禁用闪光?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图在Firefox中禁用闪光灯在Python中硒,使用配置文件设置。 这个问题指定方式,通过GUI来做到这一点,但它会更好地为这个特殊的用例以编程方式做到这一点。具体而言,最佳的解决方案将允许Flash在一个新创建的配置对象被禁用。

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.

非常感谢!

推荐答案

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

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)

这篇关于如何在Firefox中使用Python硒禁用闪光?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆