在学习[python+selenium]自动化测试时,未定义tearDown方法来将webdriver的实例关闭,导致执行多次测试案例时发生告警。
告警信息:
![[python+selenium+unittest]ResourceWarning资源警告报错](https://www.sankumao.com/wp-content/themes/justnews/themer/assets/images/lazy.png)
ResourceWarning: unclosed <socket.socket fd=552, family=AddressFamily.AF_INET6, type=SocketKind.SOCK_STREAM, proto=0, laddr=('::1', 54528, 0, 0), raddr=('::1', 54525, 0, 0)>
return self.run(*args, **kwds)
解决方式:
定义tearDown方法后解决该问题,及时释放资源
def tearDown(self) -> None:
self.driver.quit()
原创文章,作者:三酷猫,如若转载,请注明出处:https://www.sankumao.com/3517.html