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

Posted sleeping_cat

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了禁用Chrome浏览器的PDF和Flash插件相关的知识,希望对你有一定的参考价值。

#!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插件的主要内容,如果未能解决你的问题,请参考以下文章