1

i am trying to create a variable in the variables section but by appreciating it i am doing something wrong.

so I have it now and it works.

*** Variables ***


*** Test Cases ***
MyTest
    ${DATA}=     read_csv_file     ../data.csv
    Log     ${DATA}

read_csv_file is a keyword that i design.

I would like it to work like this. but the log only shows "read_csv_file ../data.csv"

*** Variables ***
${DATA}=     read_csv_file     ../data.csv

*** Test Cases ***
MyTest
    Log     ${DATA}
1
  • No, that's not supported. Commented May 14, 2020 at 4:46

1 Answer 1

3

The Variables section does not allow to execute keywords, only to define variables, eventually using other variables.

To do what you want, you need to add a Variables python file import, where you can pass an argument to it. For example:

*** Settings ***
Library           SomeLibrary.py
Variables         variables_from_csv_file.py    ../data.csv

Your variables_from_csv_file.py file would then call your reader and define the ${DATA} variable, like for example:

from mylib import read_csv_file

def get_variables(args):
        data = { "DATA": read_csv_file(args) }
        return data

See Variable files

Sign up to request clarification or add additional context in comments.

2 Comments

Sorry about the delay in responding. I understand the idea, but now how can I access the variable. if you wanted to make a Log of the read data, just put "Log ${DATA}" or do you have to define the variable? that part is not clear to me
I hope you have tried by now, Log ${DATA} or Log Many ${DATA}.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.