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.

Declaring variable at suite level

Jayaranjani_g
Jayaranjani_g Posts: 16

How to declare a variable at suite variable and assign it from Java class?

Tagged:

Comments

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭

    Variables are declared on the Variables tab in the Test Suite editor. Once delcared, you can get or set a variable's value from a scripted field or Extension tool where you can specify Java method or script. One of the arguments passed to your method is an object of type com.parasoft.api.ScriptingContext. It has methods "getValue(String variableName)" and "setValue(String variableName, String value)".

    The docs have some addition detail. See Defining Variables.

  • Jayaranjani_g
    Jayaranjani_g Posts: 16

    Thanks for your reply. I have set value in my java class like this. etc.setValue("encryPass", encPass);

    And declared variable in test suite EncrpyPass = Value = etc.getValue("encryPass")

    But still in the request the password value is going like below:

    "pwd":"etc.getValue(\"ecrypPassword\")"

    Please suggest me solution

  • benken_parasoft
    benken_parasoft Posts: 1,228 ✭✭✭
    edited April 2019

    First, is the name of your test suite variable "encryPass" or "EncrpyPass" or "ecrypPassword"? Check for typos. Case matters as well.

    Second, make sure the variable is declared prior to being set. The "setValue" method will return false if you tried to set the value of a test suite variable that is not found.

  • Jayaranjani_g
    Jayaranjani_g Posts: 16

    Hi Benken, Thanks for the reply.

    EncrpyPass is the name of the test suite variable.
    ecrypPassword is the string variable.

    Yes the variable is declared prior to set.

    But still in the request the password value is going like below:

    "pwd":"etc.getValue(\"ecrypPassword\")"

  • Jayaranjani_g
    Jayaranjani_g Posts: 16

    Thank you this is resolved

Tagged