New to Telerik Test Studio? Download free 30-day trial

Pass a Variable Between Tests

I would like to capture data in one test and pass it to another. Is it possible to set a variable in one test and have it accessible by another test in the project?

Solution

This is possible using the Extraction and Test as Step features.

  1. Create a project and add two tests: Parent and Child.

  2. Open the Parent test.

  3. Click Record and navigate to a random word generator site.

  4. Perform an Extraction on the word.

    Extract

  5. Edit the DataBindVariableName for the Extract step.

    Rename the variable

  6. Open the Child test.

  7. Record steps that navigate to www.bing.com, enter a search query, and click the submit button.

  8. Bind the variable to the Enter Text step. Type the name of the variable manually (randomWord), click the brackets and the Set button.

    Bind the child test

  9. Load the Parent test again.

  10. Add the Child test to it via the Test as Step feature.

    Test as Step

  11. Execute the Parent test.

  12. The random word is extracted in the Parent test and used as the search query in the Child test.

You can also perform an Extraction in the Child test and pass that variable back to the Parent test.

In this article