Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to get the environment variable value using jython in soatest?

brawal
brawal Posts: 26

How to get the environment variable value using jython in soatest?

I need to pass the Env Variables in the service request file with scripted option, How can I pass it?
I have used the following option but get the NONE result.

def getTestCdValue(input,context):
testcd = context.getEnvironmentVariableValue("environmentVariableName");
print 'testcd ID: ' , testcd
Application.showMessage(str(testcd))
return str(testcd)

Tagged:

Answers

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited November 2023

    The "getEnvironmentVariableValue" method does work. Perhaps you have a typo or misspelled the variable name? Or perhaps you have the variable defined in one environment but not the one that's enabled when running the tests?

    Assuming you are trying to get the "TESTCD" variable you should be calling context.getEnvironmentVariableValue("TESTCD").