Robot Framework:如何将控制台输出重定向到文件

问题描述:

我想知道是否有可能将Robot Framework的stdout从控制台重定向到文件?目前,当我运行pybot时,输出是在命令提示符下(对于Windows),我可以改变它以便它会转到一个文件吗? (没有显示在命令提示符下)。Robot Framework:如何将控制台输出重定向到文件

+1

您是否尝试过正常的方式来重定向输出? 'robot ...> console.txt'? –

+0

嗨布莱恩,我认为这是我所需要的,尽管我还没有尝试过。我的目的是将控制台输出显示到日志仪表板,类似于Jenkins在控制台输出中执行的操作。稍后再试。非常感谢! – Ryan

除了从@Bryan的建议,如果你想你的输出(XML,记录,报告)重定向到一个特定的目录或文件,可以使用下列选项为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 
+0

Hi @ Daemon12。谢谢你。不过,我已经知道Robot Framework有这个功能。我想要的是实时捕获控制台输出并将其显示在日志控制面板中(类似于Jenkins在其控制台日志中所做的)。我认为Bryan的评论就是我正在寻找的。 :-) 谢谢! – Ryan

也许你只是想给你安慰(在詹金斯的情况下),以记录它:

*** 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服务器上,你可以只是管道机器人命令行发球

robot -d results <test name>.robot | tee <test name>.out