【Python】【selenium】如何禁止测试时浏览器弹出信息

【背景】

selenium+webdriver进行测试时,如果不做一些预设,经常就会弹出一些提醒或者警告信息,让测试变得麻烦,如何在预设中消除这些信息提醒呢?

【代码】

options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--disable-notifications')

先声明一个wedriver的options实例,这里用的是Chrome的WebDriver,所以用的是ChromeOptions。
接着添加相应的argument。

猜你喜欢

转载自blog.csdn.net/weixin_41697242/article/details/125460911