在学习python selenium自动化测试学习中遇到HTMLTestRunner测试报告出现乱码的问题

HTMLTestRunner的报告中文乱码

解决办法:

网上查找到HTMLTestRunner测试报告中文乱码的解决方案:

(1)打开HTMLTestRunner.py源文件,找到如下行

# o and e should be byte string because they are collected from stdout and stderr?
        if isinstance(o,str):
            # TODO: some problem with 'string_escape': it escape \n and mess up formating
            # uo = unicode(o.encode('string_escape'))
            uo = o.decode('latin-1')
        else:
            uo = o
        if isinstance(e,str):
            # TODO: some problem with 'string_escape': it escape \n and mess up formating
            # ue = unicode(e.encode('string_escape'))
            ue = e.decode('latin-1')
        else:
            ue = e

(2)添加utf-8的解码

 

 

# o and e should be byte string because they are collected from stdout and stderr?
        if isinstance(o,str):
            # TODO: some problem with 'string_escape': it escape \n and mess up formating
            # uo = unicode(o.encode('string_escape'))
            #uo = o.decode('latin-1')
            uo = o.decode('utf-8')
        else:
            uo = o
        if isinstance(e,str):
            # TODO: some problem with 'string_escape': it escape \n and mess up formating
            # ue = unicode(e.encode('string_escape'))
            #ue = e.decode('latin-1')
            ue = e.decode('utf-8')
        else:
            ue = e
HTMLTestRunner的报告中文乱码

相关文章:

  • 2022-02-01
  • 2021-09-25
  • 2022-12-23
  • 2022-12-23
  • 2021-05-22
  • 2022-01-23
  • 2021-10-18
猜你喜欢
  • 2021-09-28
  • 2022-12-23
  • 2021-07-14
  • 2021-11-01
  • 2021-11-01
  • 2021-07-08
相关资源
相似解决方案