通过创建关键字实现:在本地html报告的同级路径,创建LOGPATH\测试套件\测试用例名\test_log.txt 并把要打印的变量同时保存在txt日志中。
该关键字有两个功能,第一个参数如果不为空,就存入txt文件;如果为空就创建文件的链接,可放在测试用例最后用于总结。
Log Info to Txt
[Arguments] ${messages}=
[Documentation] 【关键字描述】
... 把测试中的重要信息存入txt文件,放在HTML报告同级路径,并以Test Case名称命令文件夹。
${file_path} Set Variable ${OUTPUT_DIR}\\${SUITE NAME.replace('.','\\')}\\${TEST NAME}\\test_log.txt
${txt_file_info} BuiltIn.Run Keyword If '''${messages}''' == '' OperatingSystem.Get File ${file_path}
BuiltIn.Run Keyword If '''${messages}''' == '' log <h2 style="color:green; font-size:18px;"> =========================Test Summary, Please Check=========================</h2><br><span style="color:green; font-size:13px;">${txt_file_info}\n\n</span><br><a style="background-color:yellow; font-size: 18px;" target="_blank" href="${SUITE NAME.replace('.','\\')}\\${TEST NAME}">请单击跳转到截图与日志位置!</a> HTML
... ELSE Append To File ${file_path} ${messages}\n
[Teardown]
RIDE截图:
HTML报告中的索引: