1
votes

I'm new to Robot Framework, I have created this code to create a folder of current date but now I don't know how to use it at the time of test suite run. So that whenever I run my suite it will store in separate folder i.e. date wise. This the code for create Folder with system date:

*** Keywords****
Create Folder
    ${Resultdir}= C:/Users/xyz 
        ${date}= Get Current Date result_format=%d-%m-%y 
        ${date}= Convert to String ${date} 
        create directory ${Resultdir}/${date}

Currently I'm using this command to create dir:

robot -d Results\Default --log NONE  --output NONE --report NONE  Tests/GeneralTestSuite/CreateResultFolder.robot

I want this code at : pybot -d {CurrentDirecory} Test\TestSuite\Abc.robot

2
"I have created a code" - please show the code then. Please see how to ask a good question and please include a minimal, verifyable and complete example.Thomas Flinkow
${Resultdir}= C:/Users/xyz ${date}= Get Current Date result_format=%d-%m-%y ${date}= Convert to String ${date} create directory ${Resultdir}/${date}Abhilash John
please edit your question and add all relevant information there.Gilles Gouaillardet
and I'm using PyCharm IDEAbhilash John
When you say "So that whenever I run my suite it will store in separate folder i.e. date wise. ", what do you mean by "it will store"? What are you wanting to store? Are you wanting a test to create the folder that the test reports are written to?Bryan Oakley

2 Answers

2
votes

You can't change the report directory once the test has started running. Your only choice is to create the folder outside of the test, and specify the folder location on the command line.

0
votes

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 named 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