码迷,mamicode.com
首页 > 其他好文 > 详细

禁用Chrome浏览器的PDF和Flash插件

时间:2018-01-13 14:25:33      阅读:463      评论:0      收藏:0      [点我收藏+]

标签:otto   options   cat   www   excludes   main   border   setup   dem   

#!usr/bin/env python  
#-*- coding:utf-8 -*-  
#禁用Chrome浏览器的PDF和Flash插件

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import unittest,time

class TestDemo(unittest.TestCase):
    def setUp(self):
        chrome_options = Options()
        profile = {plugins.plugins_disables:[Chrome PDF Viewer,Adobe Flash Player]}
        chrome_options.add_experimental_option(prefs,profile)
        chrome_options.add_argument(--disable-extensions)
        chrome_options.add_experimental_option            (excludeSwitches,[ignore-certificate-errors])
        chrome_options.add_argument(--start-maximized)
        self.driver = webdriver.Chrome(chrome_options = chrome_options)

    def test_forbidPdfFlashChrome(self):
        self.driver.get(http://www.iqiyi.com)
        time.sleep(50)
        self.driver.get(chrome://plugins/)
        time.sleep(20)

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

if __name__ == __main__:
    unittest.main()

禁用Chrome浏览器的PDF和Flash插件

标签:otto   options   cat   www   excludes   main   border   setup   dem   

原文地址:https://www.cnblogs.com/sleeping-cat/p/8278788.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!