Passing Variables Between API and Web&Desktop Projects

When an API test is executed as a step in a Web&Desktop test, we often need to get a value that is acquired from a http response in the API test and use it in the Web&Desktop test or vice versa. To do that, all you need to do is to extract it into a variable. Any variable extracted in the API test by a Set Variable Step becomes available in the context of the Web&Desktop test and any variable extracted in the Web&Desktop test can be set as project level variable for an API test.

Passing a Variable Generated from an API Test

The variables generated from the API test execution which could be passed back to the web test are only these set in a Set Varaible Step.

Since the variable is not defined in Test Studio UI it is treated as it is a varaible extracted in code. Simply type the variable name in the text box (without the $ notation), click on the brackets and then on the Set button to apply the changes.

Use variable from API test in a web test

Passing a Variable Generated from a Web Test

Each Execute API test step has an additional property named Variables.

Variables property

Click on the down arrow to expand the Variables pane. Use the Add button to set a new variable using an extracted value from the web test.

Varianle pane

Define the variable with a name and value.

  • What is listed in the Name field will be used in the API project to reference the variable.
  • The Value field determines which extracted variable from the web test to be used. As it will be used in the API project the value can be passed using the API testing convention using double curly brackets - {{extracted-from-web-test-variable-name}}.

Add Varianle

The variable defined and set from a web test will be set as a project level variable in the API project.

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy