python2+uiautomator2自动化测试脚本改python3+uiautomator2方法,逆向就是python3改python2
- 输出自动化报告修改(第1条、第4条、第5条名称需要相对应一致)
HTMLTestRunnerEN修改为HTMLTestRunner
import HTMLTestRunnerEN #python2
import HTMLTestRunner #python3
- “print” Python2 和python3区别(python2不需要括号,python3必须需要括号)
print "打开训练识别"修改为print (“打开训练识别”)
print "打开训练识别"#python2
print("打开训练识别")#python3
- file修改为open
fp =file(now+filename,'wb') #python2
fp =open(now+filename,'wb') #python3
- 修改HTMLTestRunnerEN修改为HTMLTestRunner(第1条、第4条、第5条名称需要相对应一致)
runner = HTMLTestRunnerEN.HTMLTestRunner(stream=fp,title=u"自动化测试报告",description=u"TestCase Report")#python2
runner = HTMLTestRunner.HTMLTestRunner(stream=fp,title=u"自动化测试报告",description=u"TestCase Report")#python3
- 导入新的(python3)自动化测试报告库(第1条、第4条、第5条名称需要相对应一致)
HTMLTestRunner.py文件导入D:\Python37\Lib
需要HTMLTestRunner.py文件的请到此QQ群822659419自取