如何重新运行失败的测试Python Webdriver测试?

问题描述:

我无法重新运行失败的python webdriver测试。我正在使用unittest进行测试执行。如何重新运行失败的测试Python Webdriver测试?

已尝试使用flaky但未成功。

+0

删除不必要的介绍和关闭。 – rlandster

能够解决这个问题。

下面是相同的示例代码:

import HTMLTestRunner 
import os 
import unittest 

def testsuite(): 
    suite = unittest.TestSuite() 
    suite.addTest("Add your test here") 


    return suite 

reportloc = os.getcwd() 
outfile = open(reportloc + "TestReport.html", "w") 
executor = HTMLTestRunner.HTMLTestRunner(stream=outfile, title="Test Report", description="Tests") 

envresult = executor.run(testsuite()) 
if envresult.error_count >= 1 or envresult.failure_count >= 1: 
    executor.run(testsuite()) 

测试套件将再次再次如果任一试验箱子具有故障或错误执行。