小编use*_*577的帖子

类型错误:write() 参数必须是 str,而不是 bytes,UTF-16

所以我正在使用 Selenium 和 python 运行测试用例,并且我想为这些测试生成 HTML 测试报告。我发现这个资源应该为我做这件事,http://tungwaiyip.info/software/HTMLTestRunner.html,以防有人感兴趣,它看起来真的很好,但我不断收到此错误。

File "facebook.py", line 21, in <module>
HTMLTestRunner.main()
File "C:\Users\kporika\AppData\Local\Programs\Python\Python35-32\lib\unittest\main.py", line 94, in __init__
self.runTests()
File "C:\Users\kporika\PycharmProjects\Partha\HTMLTestRunner.py", line 816, in runTests
unittest.TestProgram.runTests(self)
File "C:\Users\kporika\AppData\Local\Programs\Python\Python35-32\lib\unittest\main.py", line 255, in runTests
self.result = testRunner.run(self.test)
File "C:\Users\kporika\PycharmProjects\Partha\HTMLTestRunner.py", line 631, in run
self.generateReport(test, result)
File "C:\Users\kporika\PycharmProjects\Partha\HTMLTestRunner.py", line 688, in generateReport
self.stream.write(output.encode('UTF-16'))
TypeError: write() argument must be str, not bytes
Run Code Online (Sandbox Code Playgroud)

测试报告生成器的代码位于https://github.com/tungwaiyip/HTMLTestRunner/blob/master/HTMLTestRunner.py创建者的 github 页面。我该如何解决?

ps 我正在运行 python 3.5 版本,如果有帮助的话。

python selenium typeerror selenium-webdriver

2
推荐指数
1
解决办法
3105
查看次数

标签 统计

python ×1

selenium ×1

selenium-webdriver ×1

typeerror ×1