3

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).

2
  • 3
    Have you tried the normal way to redirect output? robot ... > console.txt? Commented Apr 28, 2016 at 11:53
  • Hi Bryan, I think this is what I need, though I haven't tried it yet. My purpose is to display the console output to a log dashboard, similar to what Jenkins is doing in it's console output. Will try this later. Many thanks! Commented Apr 29, 2016 at 5:41

4 Answers 4

2

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. 
Sign up to request clarification or add additional context in comments.

Comments

2

On a linux server you can just pipe the robot commandline to tee

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

Comments

1

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 

1 Comment

Hi @Daemon12. Thanks for this. However, I'm already aware that Robot Framework has this. What I wanted was to capture real-time the console output and display it in a log dashboard (similar to what Jenkins does in its console log.) I think Bryan's comment is what I'm looking for. :-) Thanks!
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) 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.