【发布时间】:2014-02-06 16:23:11
【问题描述】:
我正在尝试 Selenium+Python,在研究了一些关于生成报告的好方法后,我遇到了“HTMLTestRunner”,问题是我在互联网,它们都是一样的,但是当我试图让它在我的代码上工作(主要按播放)时,我看不到生成的报告,我没有收到任何错误,你能帮帮我吗请? 这是我正在使用的代码:
class TestPruebaTest(unittest.TestCase):
def setUp(self):
self.driver = webdriver.Firefox()
self.verificationErrors = []
def testName(self): #Some logic on the code passing driver to another class and return
driverUtilizoPrueba = self.driver
manejadorLogicaBMI = logicaBMI.logicaBMI(driverUtilizoPrueba,url)
manejadorLogicaBMI.logicaPrograma()
def tearDown(self):
self.driver.quit()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestPruebaTest))
dateTimeStamp = time.strftime('%Y%m%d_%H_%M_%S')
buf = file("TestReport" + "_" + dateTimeStamp + ".html", "wb")
runner = HTMLTestRunner.HTMLTestRunner(
stream=buf,
title='Test the Report',
description='Result of tests'
)
runner.run(suite)
【问题讨论】:
-
当您说“按下播放”时,您是指在 IDE 中吗?我只是根据我自己的经验询问,如果您的
main从命令行运行,我只会生成html文件。 -
是的,我的意思是我的 IDE,是的,显然这将从命令行运行,但同时我想首先使用 IDE 对其进行测试,因为这是我正在开发的地方功能
-
感谢您的信息。我很感激这种挫败感,但我的意思是,也许还不够清楚,是测试/调试您的 html 输出是您应该从命令行运行它,即使在您编写代码的测试期间也是如此。
标签: python selenium selenium-webdriver