![](/img/trans.png)
[英]How to hide the console output while using robot.rebot command in Robot Framework?
[英]Robot Framework: How to redirect console output to file
我想知道是否有可能將Robot Framework的stdout從控制台重定向到文件? 目前,當我運行pybot時,輸出是在命令提示符下(對於Windows),我可以更改它以便它將轉到文件嗎? (命令提示符下沒有顯示任何內容)。
除了@Bryan的建議外,如果要將輸出(xml,log,report)重定向到特定目錄或文件,可以使用以下pybot
腳本選項:
-d --outputdir dir Where to create output files. The default is the
directory where tests are run from and the given path
is considered relative to that unless it is absolute.
-o --output file XML output file. Given path, similarly as paths given
to --log, --report, --xunit, and --debugfile, is
relative to --outputdir unless given as an absolute
path. Other output files are created based on XML
output files after the test execution and XML outputs
can also be further processed with Rebot tool. Can be
disabled by giving a special value `NONE`. In this
case, also log and report are automatically disabled.
Default: output.xml
-l --log file HTML log file. Can be disabled by giving a special
value `NONE`. Default: log.html
Examples: `--log mylog.html`, `-l NONE`
-r --report file HTML report file. Can be disabled with `NONE`
similarly as --log. Default: report.html
也許你只想將它記錄到你的控制台(如果是詹金斯):
*** Keywords ***
Log To Current Console
[Arguments] ${TO_LOG}
Log To Console \n\n${TO_LOG}
或者有時檢查機器人測試的調試很好:
-b --debugfile file Debug file written during execution. Not created
unless this option is specified.
在Linux服務器上,您只需將機器人命令行傳送到tee即可
robot -d results <test name>.robot | tee <test name>.out
如果你從代碼運行,你可以做類似的事情
import robot.run
with open("message_out.log", "w") as log_file_out, open("message_err.log", "w") as log_file_err:
robot.run("test",
stdout=log_file_out,
stderr=log_file_err)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.