Reputation: 63
I want to keep reports in different directory every time the execution is done, but it should be done dynamically in automation execution itself
specifying the reports directory path in command line execution is not the one I am looking for, that is there but it needs manual input to place the reports in particular directory.
Upvotes: 0
Views: 1224
Reputation: 7281
You can use a script to generate command line arguments for Robot Framework using the Reading argument files from standard input functionality.
To create a folder for the reports based on some logic, for example to name the folder as the current time and set that as the output directory, something like this can be done:
import datetime
import os
time = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
dirpath = str(time)
if not os.path.exists(dirpath):
os.makedirs(dirpath)
print('--outputdir ' + dirpath)
You have to execute your tests like:
python OutputDirArgumentFile.py | robot --argumentfile STDIN my_test.robot
Upvotes: 2
Reputation: 156
The other alternative which we can use to dynamically generate reports, is to create output directory based on current timestamp and generate Robot results there.
For example, in the below Maven robotframework plugin, the "outputDirectory" tag has location where Robot results will be stored. This location is timestamped due to which every run of robot will generate report in different directory.
<plugin>
<groupId>org.robotframework</groupId>
<artifactId>robotframework-maven-plugin</artifactId>
<version>1.4.7</version>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<testCasesDirectory>
....
</testCasesDirectory>
<variableFiles>
<variableFiles>....</variableFiles>
</variableFiles>
<outputDirectory>/myloca/reports/${maven.build.timestamp}/</outputDirectory>
<libdoc/>
<testdoc/>
</configuration>
</plugin>
Upvotes: 2
Reputation: 386325
Once the test starts running you cannot change the location of the outputs. Your only solution is to use a command line option.
Upvotes: 2