Reputation: 117
I was wondering if it was possible to redirect Robot Framework's stdout from console to file? Currently, when I run pybot, the output is in the command prompt (for Windows), can I change it in such a way that it will go to a file instead? (Nothing displayed on the command prompt).
Upvotes: 3
Views: 10453
Reputation: 1
If you run from code, you can do something like
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)
Upvotes: 0
Reputation: 113
On a linux server you can just pipe the robot commandline to tee
robot -d results <test name>.robot | tee <test name>.out
Upvotes: 2
Reputation: 9440
Maybe you just want to log it to you console (in case of Jenkins):
*** Keywords ***
Log To Current Console
[Arguments] ${TO_LOG}
Log To Console \n\n${TO_LOG}
Or sometimes it is nice to check the debug of your robot tests:
-b --debugfile file Debug file written during execution. Not created
unless this option is specified.
Upvotes: 2
Reputation: 3421
Apart from the suggestion from @Bryan, if you want to redirect your output (xml, log, report) to a particular directory or a file, you can use following options for pybot
script:
-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
Upvotes: 1