1. 程式人生 > >python+selenium自動化測試框架(2)

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)
###還有就是