Pass a Variable Between Tests

PROBLEM

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.
  5.  

     

  6. Edit the DataBindVariableName for the Extract step.
  7.  


     

  8. Open the Child test.
  9. Record steps that navigate to www.bing.com, enter a search query, and click the submit button.
  10. Bind the variable to the Enter Text step.
  11.  

    Select the Bindings drop-down and type the variable name

     

  12. Load the Parent test again.
  13. Add the Child test to it via the Test as Step feature.
  14.  


     

  15. Execute the Parent test.
  16. 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.

  1. Load the Child test and click Record to add new steps.
  2.  


     

  3. Edit the DataBindVariableName for the Extract step.
  4.  


     

  5. Open the Parent test.
  6. Add steps that navigate to www.ask.com, enter a search query, and click the submit button.
  7. Bind the variable to the Enter Text step.
  8.  

    Data bind to extracted variable

     

  9. Execute the Parent test.
  10. The random number is extracted in the Child test and used as the search query in the Parent test.