当前位置:网站首页>selenium备忘录:selenium\webdriver\remote\remote_connection.py:374: ResourceWarning: unclosed<xxxx>解决办法
selenium备忘录:selenium\webdriver\remote\remote_connection.py:374: ResourceWarning: unclosed<xxxx>解决办法
2022-07-02 06:22:00 【bthtth】
报错代码及截图
from selenium import webdriver
driver = webdriver.Edge()
driver.get("https://sjz.58.com/")
driver.maximize_window()
报错信息如下:
XXXXX ResourceWarning: unclosed <socket.socket xxxx>
return self._request(command_info[0], url, body=data)
解决办法
网上大部分大方法是ignore warning 方法,这个比较好搜,可以自己搜.
另外一种方法是从根本解决问题,我比较认同。原文在后面,也比较感谢博主.
Edge()有一个初始化参数keep-live,用来设置长连接,默认值为False.
`class WebDriver(RemoteWebDriver):
def __init__(self, executable_path='MicrosoftWebDriver.exe',
capabilities=None, port=0, verbose=False, service_log_path=None,
log_path=None, keep_alive=False)
`
如果使用默认值,就会resourcewarning.所以在创建driver实例的时候,将keep_alive=True传入就好
from selenium import webdriver
driver = webdriver.Edge(keep_alive=False)
driver.get("https://sjz.58.com/")
driver.maximize_window()
原文
链接: link.
边栏推荐
猜你喜欢
随机推荐
FE - weex 开发 之 使用 weex-ui 组件与配置使用
Kotlin - 验证时间格式是否是 yyyy-MM-dd HH:mm:ss
Singleton mode compilation
【程序员的自我修养]—找工作反思篇二
Pbootcms collection and warehousing tutorial quick collection release
Code skills - Controller Parameter annotation @requestparam
PgSQL学习笔记
深入学习JVM底层(二):HotSpot虚拟机对象
一起学习SQL中各种join以及它们的区别
The intern left a big hole when he ran away and made two online problems, which made me miserable
BGP 路由優選規則和通告原則
Redis - hot key issues
压力测试修改解决方案
State machine in BGP
分布式事务 :可靠消息最终一致性方案
利用NVIDIA GPU将Minecraft场景渲染成真实场景
In depth understanding of JUC concurrency (I) what is JUC
LeetCode 90. Subset II
LeetCode 47. Full arrangement II
BGP routing optimization rules and notification principles
![Data science [9]: SVD (2)](/img/2c/f1a8c3ff34ff3f3cc6e26157a32bfd.png)








