#!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()
原文地址:https://www.cnblogs.com/sleeping-cat/p/8278788.html
时间: 2024-09-30 06:59:21