python3 Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接
Posted 无意多说
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python3 Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接相关的知识,希望对你有一定的参考价值。
报错源代码
from selenium import webdriver
import unittest
import time
from HTMLTestRunner import HTMLTestRunner
class BaiDu(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Chrome()
self.driver.maximize_window()
self.driver.implicitly_wait(10)
self.base_url = "http://www.baidu.com"
def test_baidu(self):
driver = self.driver
driver.get(self.base_url + "/")
driver.find_element_by_id("kw").clear()
driver.find_element_by_id("kw").send_keys("HTMLTestRunner")
driver.find_element_by_id("su").click()
time.sleep(2)
def tearDown(self):
self.driver.quit()
self.driver.close()
if __name__ == "__main__":
testunit = unittest.TestSuite()
testunit.addTest(BaiDu("test_baidu"))
# 定义报告存放路径
fp = open("E:/result.html", \'wb\')
# 定义测试报告
runner = HTMLTestRunner(stream=fp, title=\'百度搜索测试报告\', description=\'用例执行情况:\')
runner.run(testunit) # 运行测试用例
fp.close() # 关闭报告文件
解决办法:
把self.driver.close()去掉,即可恢复!
以上是关于python3 Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接的主要内容,如果未能解决你的问题,请参考以下文章
win10安装Anaconda3出现failed to create anacoda menue错误的解决方案
PX4编译报:Failed to import toml: No module named 'toml'错误解决方法
RuntimeError: lines.type().is_cuda()INTERNAL ASSERT FAILED at ““, please report a bug to PyTorch.
RuntimeError: lines.type().is_cuda()INTERNAL ASSERT FAILED at ““, please report a bug to PyTorch.
安装Intel HAXM:"failed to configure driver unknown error. failed to open driver"