Forum Discussion

vibhashenoy's avatar
vibhashenoy
Occasional Contributor
8 years ago
Solved

Can we pass variables from a KeywordTest to a script and vice versa?

Hey,  I was trying to use variables across keyword tests and scripts, tried writing the following in the script but it did not execute

varname = KeywordTest.KeywordTestName.Variable.VariableByName("VariableName")

Is there any other way to pass variables across keyword tests and scripts? 

 

  • Your code is correct, however your should check where you have call your variable, because KeywordTest variables are not accessible from other keyword tests. If so, you should use Project or ProjectSuite variables.

4 Replies

  • baxatob's avatar
    baxatob
    Community Hero

    Your code is correct, however your should check where you have call your variable, because KeywordTest variables are not accessible from other keyword tests. If so, you should use Project or ProjectSuite variables.

    • vibhashenoy's avatar
      vibhashenoy
      Occasional Contributor

      Hey. Thanks for the reply.
      So I declared a variable at the project suite level and tried accessing it in my script using 

      newva = ProjectSuite.Variables.VariablebyName("Varname")

       where Varname is my suite level variable. It returns null when i try to print it. Is there another way through which I can access the suite level variable?

      • baxatob's avatar
        baxatob
        Community Hero

        Check carefully your assignment for this variable. If it returns null, it was not assigned by another value.