首页 > Web开发 > 详细

禁用Firefox浏览器中的CSS、Flash及Image加载

时间:2018-01-13 14:01:32      阅读:285      评论:0      收藏:0      [点我收藏+]
#!usr/bin/env python  
#-*- coding:utf-8 -*-  
#禁用Firefox浏览器中的CSS、Flash及Image加载

from selenium import webdriver
import time,unittest

class TestDemo(unittest.TestCase):
    def setUp(self):
        #创建Firefox浏览器的一个Options实例对象
        profile = webdriver.FirefoxProfile()
        #禁用CSS加载
        profile.set_preference(permissions.default.stylesheet,2)
        #禁用images加载
        profile.set_preference(permissions.default.image,2)
        #禁用flash插件
        profile.set_preference(dom.ipc.plugins.enabled.libflashplayer.so,False)
        #启动带有自定义设置的Firefox浏览器
        self.driver = webdriver.Firefox(firefox_profile= profile)

    def test_forbidImageFirefox(self):
        self.driver.get(http://www.iqiyi.com)
        time.sleep(10)

    def tearDown(self):
        self.driver.quit()

if __name__ == __main__:
    unittest.main()

禁用Firefox浏览器中的CSS、Flash及Image加载

原文:https://www.cnblogs.com/sleeping-cat/p/8278805.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!