zoukankan      html  css  js  c++  java
  • 禁用Firefox浏览器中的CSS、Flash及Image加载

    #!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()
  • 相关阅读:
    iOS截取长图,自定义截取size
    工作
    UITableView适配iOS11
    利用脚本实现build号自动加一
    iOS原生与JS互调
    CSS高级技巧
    伪元素选择器
    CSS设置过渡
    CSS文本属性 二
    css设置圆角矩形
  • 原文地址:https://www.cnblogs.com/sleeping-cat/p/8278805.html
Copyright © 2011-2022 走看看