Python Selenium - ResourceWarning: Enable tracemalloc to get the object allocation traceback

给你一囗甜甜゛ 提交于 2020-07-20 04:33:02

问题


I am using BrowserStack to run Selenium scripts in Python. Keep in mind that I am new in Python, so maybe there is a simple solution to this that I am not seeing.

You can see the code here

When I run it, it always shows the following:

How to I solve the "ResourceWarning: Enable tracemalloc to get the object allocation traceback" error? Do I need to install some package, enable something in the settings, or..? The tests always execute, as you can see at the bottom, but these Warnings always appear.


回答1:


As mentioned in here!

This ResourceWarning means that you opened a file, used it, but then forgot to close the file. Python closes it for you when it notices that the file object is dead, but this only occurs after some unknown time has elapsed. Thus in recent versions, Python also prints a ResourceWarning when it does that.




回答2:


The tracemalloc module is a debug tool to trace memory blocks allocated by Python. You may refer to this for more details: https://docs.python.org/3/library/tracemalloc.html

Hence it is just a warning which is asking you to enable tracemalloc and not an error. This won't affect your test case.



来源:https://stackoverflow.com/questions/60945317/python-selenium-resourcewarning-enable-tracemalloc-to-get-the-object-allocati

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!