Katalon Analytics (beta) – Bringing new insights into test reports. Learn more!

Create/change variables from test script

Hi guys, I'd like to ask if it is possible to create and change global variables in a test case.

I want to pass a variable from TC1 to TC2 (var1 is created in TC1, it finishes, TC2 starts and var1 can be used in TC2 execution).

Are there any available methods to access (global) variables? Or is there any other way how to achieve behavior I mentioned above, maybe TestData? I found only get methods in documentation, no set methods for TestData class.

Thanks!

Comments

  • Please try this link

    Example for using:

    TC1:

    import internal.GlobalVariable

    GlobalVariable.var1  = 'sample value'

    TC2:

    import internal.GlobalVariable

    println GlobalVariable.var1

     

     

     
  • It's working, thank you.
  • @duyluong said:
    Please try this link

    Example for using:

    TC1:

    import internal.GlobalVariable

    GlobalVariable.var1  = 'sample value'

    TC2:

    import internal.GlobalVariable

    println GlobalVariable.var1

     

     

     

    Thanks, This worked for me.

  • you should run these test cases in test suite and set TC1 first and then TC2

Sign In or Register to comment.