python+selenium自动化测试框架(2)

HTMLTestRunner自动化生成测试报告的使用
这个本人也是第一次使用这个工具,python2是可以直接使用的,但是python3.0不能直接拿来使用它。需要进行修改:
他是存在python里面的lib文件夹里面
打开你的HTMLTestruner.py文件:
第94行,将import StringIO修改成import io
第539行,将self.outputBuffer = StringIO.StringIO()修改成self.outputBuffer=io.StringIO()
第774行,将uo = o.decode(‘latin-1‘)修改成uo =e
第775行,将ue = e.decode(‘latin-1‘)修改成ue = e
第636,将print >> sys.stderr, ‘\nTime Elapsed: %s‘%(self.stopTime-self.startTime)修改成print(sys.stderr, ‘\nTimeElapsed: %s‘ % (self.stopTime-self.startTime))
实现它需要的代码:
suite = unittest.TestSuite()
suite.addTest(open(‘test_add’))
fileName = ‘C:/appium/reports/report.html’# 提示路径很重要
with open(fileName, ‘wb’) as fp:
runner = HTMLTestRunner(stream=fp,title=“油气站web自动化测试报告”,description=“本次测试使用的是winds10系统”)
runner.run(suite)
###还有就是

猜你喜欢

转载自blog.csdn.net/weixin_42996498/article/details/83032407