0

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
1

2 Answers 2

2

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.

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

1 Comment

While variables section does not allow this but *** Settings *** section does with Variables does. See robotframework.org/robotframework/latest/…
0

Try following: Here, you are not required to use any variables/section to call py file.

Under *** Settings *** section add

Library initpath.py

Comments

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.