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?
This is possible using the Extraction and Test as Step features.
- Create a project and add two tests: Parent and Child.
- Open the Parent test.
- Click Record and navigate to a random word generator site.
- Perform an Extraction on the word.
- Edit the DataBindVariableName for the Extract step.
- Open the Child test.
- Record steps that navigate to www.bing.com, enter a search query, and click the submit button.
- Bind the variable to the Enter Text step.
- Load the Parent test again.
- Add the Child test to it via the Test as Step feature.
- Execute the Parent test.
- 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.
- Load the Child test and click Record to add new steps.
Edit the DataBindVariableName for the Extract step.
Open the Parent test. Add steps that navigate to www.ask.com, enter a search query, and click the submit button. Bind the variable to the Enter Text step.
Execute the Parent test. The random number is extracted in the Child test and used as the search query in the Parent test.