Wednesday, December 21, 2016

Web Performance Testing with Visual Studio - Extracting login token

Introduction

Visual Studio Enterprise 2015 or Visual Studio Ultimate 2013, gives you the possibility to test the performance of your application. In this article we'll show you how to extract .json login token for later use by using a Text Extraction Rule. If you don't have this information, after login, you'll get a 401 Unauthorized error.

Extract token

First of all, run your recorded test and check the test result. Go to the request that contains the token and check Response tab. In the example below, you can notice that the access token is stored in a .json.




Using extraction rule

Extracting the token is possible, by using Extraction Rules functionality. To do this, go to your recorded request (for login), right click on request name and add new extraction rule.



Select the extraction rule of type Extract Text, enter Context Parameter Name (the name of a test variable to associate with the extracted value), Starts With and Ends With, like in the image below.



After doing this, your request should look like this.



Use token to authorize

The extracted token should be used in the requests performed after login. To do this select the request, right click and Add Header



In properties, add an Authorization header with this value: Bearer {{myToken}}.



Happy testing and... make it green, becomes a dream :)


3 comments:

  1. Thanks for sharing detailed information of unified functional testing automation tool. QTP Course in Chennai | Loadrunner Training in Chennai

    ReplyDelete
  2. Nice post! It is really very helpful for us. If anyone want to know the details about Quality Assurance Consultant in Australia Contact Us at 0414775872 or admin@pqas.com.au .

    ReplyDelete

Popular Posts