屏蔽Chrome的--ignore-certificate-errors提示及禁用扩展插件并实现窗口
#encoding=utf-8
import unittest
from selenium import webdriver
import time
from selenium.webdriver.chrome.options import Options
class TestDemo(unittest.TestCase):
def setUp(self):
# 创建Chrome浏览器的一个Options实例对象
chrome_options = Options()
# 向Options实例中添加禁用扩展插件的设置参数项
chrome_options.add_argument("--disable-extensions")
# 添加屏蔽--ignore-certificate-errors提示信息的设置参数项
chrome_options.add_experimental_option(\
"excludeSwitches",["ignore-certificate-errors"])
# 添加浏览器最大化的设置参数项,一启动就最大化
chrome_options.add_argument("--start-maximized")
# 启动带有自定义设置的Chrome浏览器
self.driver = webdriver.Chrome(executable_path = "d:\\chromedriver",\
chrome_options = chrome_options)
def test_downloadFileByChrome(self):
self.driver.get("http://www.baidu.com")
time.sleep(3)
self.driver.find_element_by_id("kw").send_keys("光荣之路")
time.sleep(5)
def tearDwon(self):
self.driver.quit()
if __name__ == "__main__":
unittest.main()
分享题目:屏蔽Chrome的--ignore-certificate-errors提示及禁用扩展插件并实现窗口
分享链接:http://azwzsj.com/article/jgeohe.html