查看ui自動化生成的html報(bào)告。pytest+allure只生成了xml報(bào)告--json格式的數(shù)據(jù),沒有生成html的index報(bào)告。
場景:
電腦配置了allure的環(huán)境變量,配置在系統(tǒng)變量下。
pycharm安裝了allure-pytest包
運(yùn)行腳本,生成xml類型報(bào)告。沒有html的報(bào)告
排查:
1.cmd輸入allure --version,查看是安裝成功

image.png
2.pycharm輸入pip freeze,查看包是否配置成功

image.png
都顯示安裝、配置成功
3.pycharm軟件Terminal中輸入allure

image.png
懷疑是pycharm軟件哪里配置除了問題,排查浪費(fèi)了N多時(shí)間。
最終總算是配置好了~

image.png
解決方法:
-
cmd = "allure generate ./Report/xml/ -o ./Report/html/ --clean"
上面這行代碼不會直接執(zhí)行,腳本里面需要shll命令去執(zhí)行
shell =Shell.Shell()
shell.invoke(cmd)
import subprocess
class Shell:
@staticmethod
def invoke(cmd):
output, errors = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
o = output.decode("utf-8")
return o
- 軟件右鍵,用管理員權(quán)限運(yùn)行pycharm,完美解決問題。

image.png