Forum Discussion

Nayak_Ragh's avatar
Nayak_Ragh
Occasional Contributor
4 years ago

Project variable to be used across different tests

I am having a Desktop application where one test captures certain dynamically generated ID and it needs to be passed as an input to another test.

 

Ex: Var1 is captured in Test1 - Unit1 script, through function InvID()

 

Now, I need to pass this Var1 as an input to one of the field in Test2.

 

Questions :

1. How do I declare the variable Var1 as global or Project variable

2. How do I call this variable, Var1, in the keyword driven testing, to pass it as an input to the new field in Test2

 

Thanks in Advance.

 

 

  • tphillips's avatar
    tphillips
    Frequent Contributor

    Hi

     

    You have already asked this question, and it's been answered for you here. Did the answer not work for you?

    Can you add more information if it's not working for you?

    • Nayak_Ragh's avatar
      Nayak_Ragh
      Occasional Contributor

      Highlevel scenario is same and I understand, we need to execute both the testcases in a sequence but here, I am trying to learn specifically how to declare variables globally / at project level in one test case and use it on another test case

       

      1. How do I declare the variable Var1 as global or Project variable in Test1

      2. How do I call this variable, Var1, in the keyword driven testing, to pass it as an input to the new field in Test2

       

       

      • tphillips's avatar
        tphillips
        Frequent Contributor

        You need to create the variable at the project or project suite level if you're using keyword tests

        If you're scripting you can add project or project suite variables in the script itself:

        Project.Variables.AddVariable("MyNewVariable", "String");

         

        Refer to the documentation for more information:

        Project/Project Suite Variables in keyword tests 

        Project/Project Suite Variables in scripts 

         

        Actually using them is much the same as in your original question in the other thread.