Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to save Robot framework test run logs in some folder with timestamp?

I am using Robot Framework, to run 50 Testcases. Everytime its creating following three files as expected:

c:\users\<user>\appdata\local\output.xml
c:\users\<user>\appdata\local\log.html
c:\users\<user>\appdata\local\report.html

But when I run same robot file, these files will be removed and New log files will be created.

I want to keep all previous run logs to refer in future. Log files should be saved in a folder with a time-stamp value in that.

NOTE: I am running robot file from command prompt (pybot test.robot). NOT from RIDE.

Could any one guide me on this?

like image 733
rcubefather Avatar asked Dec 09 '22 00:12

rcubefather


2 Answers

Using the built-in features of robot

The robot framework user guide has a section titled Timestamping output files which describes how to do this.

From the documentation:

All output files listed in this section can be automatically timestamped with the option --timestampoutputs (-T). When this option is used, a timestamp in the format YYYYMMDD-hhmmss is placed between the extension and the base name of each file. The example below would, for example, create such output files as output-20080604-163225.xml and mylog-20080604-163225.html:

robot --timestampoutputs --log mylog.html --report NONE tests.robot

To specify a folder, this too is documented in the user guide, in the section Output Directory, under Different Output Files:

...The default output directory is the directory where the execution is started from, but it can be altered with the --outputdir (-d) option. The path set with this option is, again, relative to the execution directory, but can naturally be given also as an absolute path...

Using a helper script

You can write a script (in python, bash, powershell, etc) that performs two duties:

  1. launches pybot with all the options you wan
  2. renames the output files

You then just use this helper script instead of calling pybot directly.

like image 200
Bryan Oakley Avatar answered Dec 28 '22 05:12

Bryan Oakley


I'm having trouble working out how to create a timestamped directory at the end of the execution. This is my script it timestamps the files, but I don't really want that, just the default file names inside a timestamped directory after each execution?

CALL "C:\Python27\Scripts\robot.bat" --variable BROWSER:IE --outputdir C:\robot\ --timestampoutputs --name "Robot Execution" Tests\test1.robot
like image 29
resourceful-idiot Avatar answered Dec 28 '22 06:12

resourceful-idiot