huluwahaha large avatar
测试学习小组  ›  python selenium

Python执行出现ResourceWarning,如何处理?

By huluwahaha at 一年前 , 3938 次浏览

from selenium import webdriver
import unittest,ddt
import time
import common

urls=common.get_ad_url()

@ddt.ddt
class MyTest(unittest.TestCase):

def setUp(self):
self.driver=webdriver.Chrome()
self.driver.maximize_window()
self.driver.implicitly_wait(10)

@ddt.data(*urls)
def test_ad(self,data):
#print(data)
driver=self.driver
driver.get(data)
gold1_3=driver.find_element_by_css_selector("**")
img="**"
ad_img=gold1_3.find_element_by_css_selector("div>div>div>img").get_attribute("src")
self.assertEqual(ad_img,img)

def tearDown(self):
self.driver.quit()

if name=="main":
unittest.main()

.D:\soft\python36\lib\email\feedparser.py:123: ResourceWarning: unclosed <socket.socket [closed] fd=768, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
self.lines.extend(lines)
E......D:\soft\python36\lib\socket.py:144: ResourceWarning: unclosed <socket.socket [closed] fd=768, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
_socket.socket.
init(self, family, type, proto, fileno)
D:\soft\python36\lib\socket.py:144: ResourceWarning: unclosed <socket.socket [closed] fd=720, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
_socket.socket.
init(self, family, type, proto, fileno)
D:\soft\python36\lib\socket.py:144: ResourceWarning: unclosed <socket.socket [closed] fd=368, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
_socket.socket.
init(self, family, type, proto, fileno)
D:\soft\python36\lib\socket.py:144: ResourceWarning: unclosed <socket.socket [closed] fd=820, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
_socket.socket.
init(self, family, type, proto, fileno)
D:\soft\python36\lib\socket.py:144: ResourceWarning: unclosed <socket.socket [closed] fd=816, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
_socket.socket.
init(self, family, type, proto, fileno)
D:\soft\python36\lib\socket.py:144: ResourceWarning: unclosed <socket.socket [closed] fd=744, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
_socket.socket.
init(self, family, type, proto, fileno)
D:\soft\python36\lib\socket.py:144: ResourceWarning: unclosed <socket.socket [closed] fd=616, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0>
_socket.socket.
init_(self, family, type, proto, fileno)
..

2 回复
老汉 medium avatar
#2 - 10 个月前
老汉

楼主解决了吗?怎么解决的?

测试学习小组 — 软件测试学习讨论区
现在注册
已注册用户请 登入
内容分享

欢迎关注我们的公众号: 测试圈TC


小贴士

你的问题在测试教程网中能找到答案