Jan Novak
Jan Novak

Reputation: 21

Robotframework - using environment variables in a variable file

I would like to construct a variable for RobotFramework within the variable file but using the Linux environmental variable. Could you advise on the syntax please ?? My current attempts with this:

vif_vlan       = "110"

path_scripts   = '%{MY_DIR}/my_path/scripts'

remote_path    = "/home/mcast/mgen"

end up in not expanding the env variable %{MY_DIR} ...

Tx

Upvotes: 0

Views: 2495

Answers (2)

Fusion
Fusion

Reputation: 5472

Your syntax is almost correct - Not for Python, but for Robot Framework. In your .robot files, you can retrieve environment variables as follows:

** Variables **
| ${MY_PATH_TO_SCRIPTS} | %{MY_DIR}/my_path/scripts

Upvotes: 1

Bryan Oakley
Bryan Oakley

Reputation: 385970

Environment variables are in the environ dictionary of the os module:

import os
path_scripts = os.path.join(os.environ['MY_DIR']', 'my_path', 'scripts')

Upvotes: 1

Related Questions