Reputation: 11
replace "Variables config"
with "Variables /path/CLOUD234/__init__.py"
in robot framework .Cloud instance is defined at run time .In each run the value changes ,so I have created a python file initpath.py as follows with fun() keyword .It will return the required path .How can I call it in Variables section of robot framework ? Thank you in advance.
import socket
import re
import os
def fun():
name = socket.gethostname()
pattern = ".*CLOUD[0-9]*"
hname = re.findall(pattern,name)
cloud_instance = hname[0].replace("-","_")
init_file = "/path/{}/__init__.py".format(cloud_instance)
return init_file
Upvotes: 0
Views: 296
Reputation: 118
Try following: Here, you are not required to use any variables/section to call py file.
Under *** Settings ***
section add
Library initpath.py
Upvotes: 0
Reputation: 219
Variables section do not execute any code.
I suggest you run the python under testcase/suite up and use Set Test Variable
to set the variable.
Upvotes: 2