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.
Tip
You can follow an end-to-end scenario in our blog post Power Up Your UI Tests with 'API Test as Step' in Telerik Test Studio
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.
Passing a Variable Generated from a Web Test
Each Execute API test step has an additional property named Variables.
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.
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}}.
The variable defined and set from a web test will be set as a project level variable in the API project.